当前位置: 首页 > news >正文

用火车采集器发布信息时 如何获取网站栏目id网站服务器租

用火车采集器发布信息时 如何获取网站栏目id,网站服务器租,淘宝指数查询工具,寻找外贸客户的网站import.meta.glob 是 Vite 提供的一个特殊功能#xff0c;它允许你在模块范围内动态地导入多个模块。这在处理大量的文件#xff0c;如组件、页面或其他模块时特别有用#xff0c;特别是当你需要根据某些条件或模式来动态加载它们时。 1.创建需要动态导入的组件目录 假设你…import.meta.glob 是 Vite 提供的一个特殊功能它允许你在模块范围内动态地导入多个模块。这在处理大量的文件如组件、页面或其他模块时特别有用特别是当你需要根据某些条件或模式来动态加载它们时。 1.创建需要动态导入的组件目录 假设你有一个src/pages/DynamicComponents目录里面包含多个 Vue 组件你想根据某些条件动态地导入这些组件。 首先确保你的目录结构是这样的 src/pages/index.vue文件 templatediv classDynamicComponentsOutboxh1DynamicComponents/h1/divdivcomponent v-for(component, name) in dynamicComponents :keyname :iscomponent //div /templatescript setup import { onMounted, reactive,markRaw } from vue const dynamicComponents reactive({}) onMounted(async () {const modules import.meta.glob(./DynamicComponents/*.vue);for (const path in modules) {const module await modules[path]();const componentName path.replace(/^\.\/components\/(.*)\.vue$/, $1);console.log(componentName,componentName );dynamicComponents[componentName] markRaw(module.default)}console.log(dynamicComponents,dynamicComponents); }) /scriptstyle langscss scoped/style src/pages/DynamicComponents/ComponentA.vue文件 templatediv classh1ComponentA/h1/div /templatescript setup/scriptstyle langscss scoped/style src/pages/DynamicComponents/ComponentB.vue文件 templatediv classh1ComponentB/h1/div/templatescript setup/scriptstyle langscss scoped/style App.vue文件 templatemainHelloWorld msgYou did it! /component :isDynamicComponents/component/main /template script setup import HelloWorld from /components/HelloWorld.vue import DynamicComponents from /pages/index.vue /script style scoped/styleindex.vue:6 [Vue warn]: Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with markRaw or using shallowRef instead of ref. Component that was made reactive: {__hmrId: ed2b2297, __file: C:/Users/63002/Desktop/codefile/vue3-vite2/src/pages/DynamicComponents/ComponentA.vue, render: ƒ}at Index at App 刚开始这样写  dynamicComponents[componentName] module.default  这里报了一个警告提示你去给组件使用markRaw or shallowRef包起来就好了我直接使用了markRaw来包起组件 就解决这个警告了。 改为 import { onMounted, reactive,markRaw } from vue dynamicComponents[componentName] markRaw(module.default) templatediv classDynamicComponentsOutboxh1DynamicComponents/h1/divdivcomponent v-for(component, name) in dynamicComponents :keyname :iscomponent //div /templatescript setup import { onMounted, reactive,markRaw } from vue const dynamicComponents reactive({}) onMounted(async () {const modules import.meta.glob(./DynamicComponents/*.vue);for (const path in modules) {const module await modules[path]();const componentName path.replace(/^\.\/components\/(.*)\.vue$/, $1);console.log(componentName,componentName );dynamicComponents[componentName] markRaw(module.default)}console.log(dynamicComponents,dynamicComponents); }) /scriptstyle langscss scoped/style 在上面的代码中我们首先在onMounted钩子中使用 import.meta.glob 获取 components 目录下所有 .vue 文件的动态导入。然后我们遍历这些模块加载它们并将它们存储在 dynamicComponents 对象中其中键是组件的名称从文件路径中提取值是组件的默认导出。 最后在模板中我们使用 v-for 指令遍历 dynamicComponents 对象并使用 Vue 的动态组件功能 (component :is...) 来渲染每个组件。 注意由于 import.meta.glob 是在构建时解析的因此它不会为动态路径或运行时确定的路径工作。它主要用于静态路径模式。
http://www.zqtcl.cn/news/541159/

相关文章:

  • 动画制作软件下载安装网站seo置顶
  • 怎么做网站推广的步骤关闭评论 WordPress
  • 合肥建站费用学生做兼职去哪个网站
  • 万户网络做网站如何做网站的企业排名
  • 天猫网站左侧菜单向右滑出的导航菜单阜阳h5网站建设公司
  • 凡科做网站的方法wordpress备份如何安装
  • 网站备案依据四川省广安建设局网站
  • 网站后台管理系统模板品牌营销和品牌推广
  • 网站建设的整个流程图wordpress标题去重
  • 网站手机版模板做拼货商城网站
  • wordpress建自己的网站吗c2c网站的特点
  • 建设网站的成本有哪些龙岩做网站哪家最好
  • wordpress 多站点 子目录安徽望江县城乡建设局官方网站
  • 电子政务网站建设的步骤一般为俱乐部logo免费设计在线生成
  • 网站建设尚品男生学计算机哪个专业最吃香
  • app制作网站收费吗重庆网站产品推广
  • 网站开发预算怎么算厦门建站比较好的公司
  • 涡阳网站优化建设工程公司企业文化
  • 曲靖市住房和城乡建设局网站罗湖区网站公司
  • 购物券网站怎么做wordpress+好用插件
  • 商务网站建设的一般流程是什么?南宁seo费用服务
  • 做企业网站需要什么seminar是什么意思
  • 如何把代码放在网站首页教程深圳建网站哪个公
  • 做的网站第二年续费多钱上传到服务器的网站打开是空白
  • 网站建设花多少钱怎样建移动网站
  • 关键词排名优化网站上海有几个区分别叫什么名字
  • php网站开发基础定制自己的软件
  • 私人装修接单网站wordpress热门文章插件
  • 湘潭网站外包公司宁波妇科医生推荐
  • 企业网站建设可以分为几个层次三亚网站定制