美文网首页
vue requrie.context的一些用法

vue requrie.context的一些用法

作者: Betterthanyougo | 来源:发表于2019-10-10 14:43 被阅读0次

1.注册全局组件

2.倒入 路由

子路由较多时。 可以将提取出来

代码为

export default {

Path:’/’,

name:“/”,

conponent:import…...

child:[

path:’home’,

name:“/”,

conponent:import…...

]

}

也可以作为store.module的导入

importAll(require.context('../components/', true, /\.js$/));var cache = {};functionimportAll(r){

  r.keys().forEach(key => cache[key] = r(key));

}

importAll(require.context('../components/', true, /\.js$/));// 在构建时(build-time),所有被 require 的模块都会被填充到 cache 对象中。

相关文章

网友评论

      本文标题:vue requrie.context的一些用法

      本文链接:https://www.haomeiwen.com/subject/rgtapctx.html