vue.config.js
const path=require('path')
module.exports = {
// 配置路径别名
configureWebpack: (config) => {
config.resolve.alias['@']=path.resolve(__dirname,"./");
config.resolve.alias['@store']=path.resolve(__dirname,"./store");
config.resolve.alias['@minxin']=path.resolve(__dirname,"./mixins");
config.resolve.alias['@minxins']=path.resolve(__dirname,"./mixins");
config.resolve.alias['@u']=path.resolve(__dirname,"./utils");
config.resolve.alias['@util']=path.resolve(__dirname,"./utils");
config.resolve.alias['@utils']=path.resolve(__dirname,"./utils");
config.resolve.alias['@d']=path.resolve(__dirname,"./directives");
config.resolve.alias['@c']=path.resolve(__dirname,"./directives");
config.resolve.alias['@img']=path.resolve(__dirname,"./assets/img");
config.resolve.alias['@imgs']=path.resolve(__dirname,"./assets/img");
config.resolve.alias['img']=path.resolve(__dirname,"./assets/img");
config.resolve.alias['imgs']=path.resolve(__dirname,"./assets/img");
config.resolve.alias['c']=path.resolve(__dirname,"./components");
config.resolve.alias['d']=path.resolve(__dirname,"./directives");
config.resolve.alias['u']=path.resolve(__dirname,"./utils");
config.resolve.alias['store']=path.resolve(__dirname,"./store");
config.resolve.alias['minxins']=path.resolve(__dirname,"./mixins");
config.resolve.alias['minxin']=path.resolve(__dirname,"./mixins");
config.resolve.alias['minxin']=path.resolve(__dirname,"./mixins");
},
productionSourceMap: false,
}
7 个回复
c***@163.com
同求怎么配置
1***@qq.com (作者) - 90后码农
写个json对应文件目录,改文件名字
Joyce80 - 拓荒者!!!
同求方法
1***@163.com
同求啊~~~~找了很久
1***@qq.com - 827915
vue.config.js
1***@qq.com
新建的uniapp项目为什么没有这个文件,直接@图片就有效,加上这个文件改了怎么还报错啊Module not found: Error: Can't resolve '@/logo.png'
2021-06-24 18:21
9***@qq.com
同求啊
hhyang - 如有问题,请添加QQ1606726660 备注付费咨询
uni-simple-router
aliasPath
可以解决你的烦恼示例 pages.json 中的配置