"easycom": {
"autoscan": true,
"custom": {
"^uni-(.)": "@/components/uni-$1.vue", // 匹配components目录内的vue文件
"^vue-file-(.)": "packageName/path/to/vue-file-$1.vue" // 匹配node_modules内的vue文件
}
}
![吴克](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/17/15/82_avatar_mid.jpg?v=1655049449)
![](http://img-cdn-tc.dcloud.net.cn/static/common/sponsor-1.png)
![](http://img-cdn-tc.dcloud.net.cn/static/common/sponsor-count-1.png)
- 发布:2022-03-10 01:11
- 更新:2022-03-10 02:05
- 阅读:960
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows10
浏览器平台: Chrome
浏览器版本: 96
项目创建方式: CLI
CLI版本号: 2.0.1-33920220208001
示例代码:
操作步骤:
"easycom": {
"autoscan": true,
"custom": {
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
}
}
这个是z-paging官方方式
"easycom": {
"autoscan": true,
"custom": {
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
}
}
这个是z-paging官方方式
预期结果:
正常引入
正常引入
实际结果:
Module not found: Error: Can't resolve '@/uni_modules/z-paging' in 'C:\Users\hugetiny\WebstormProjects\play\node_modules\z-
paging\components\z-paging\js'
Module not found: Error: Can't resolve '@/uni_modules/z-paging' in 'C:\Users\hugetiny\WebstormProjects\play\node_modules\z-
paging\components\z-paging\js'
bug描述:
https://uniapp.dcloud.net.cn/collocation/pages.html#easycom中官方的引入node_modules方式并不能引入
代码中 "^vue-file-(.*)": "packageName/path/to/vue-file-$1.vue"并不能匹配node_modules内的vue文件
1 个回复
吴克 (作者)
今天折腾了一天才发现
ui库必须内层引入,否则easycom识别不到,
js库又必须外层引入,否则会报exports is not defined