easycom规则*将组件引入精简为一步。只要组件安装在项目的 components 目录下,并符合 components/组件名称/组件名称.vue 目录结构。就可以不用引用、注册,直接在页面中使用。
首先去项目pages.json进行配置
"easycom": {
"autoscan": true,
"custom": {
"^uni-(.*)": "@/components/uni-$1.vue", // 匹配components目录内的vue文件
"^vue-file-(.*)": "packageName/path/to/vue-file-$1.vue" // 匹配node_modules内的vue文件
}
}
2、在页面使用的时候,首先线在项目根目录下创建components文件
3、什么叫符合components/组件名称/组件名称.vue 目录结构?
在页面直接使用
注意:如果页面使用失败时,查看是否组件命名和页面使用组件标签名不一致