1.在项目根目录下创建vue.config.js文件
2.输入以下代码
const webpack = require('webpack') const path = require('path'); function resolve(dir) { return path.join(__dirname, dir); } module.exports = { lintOnSave: true, chainWebpack: (config) => { config.resolve.alias .set('@', resolve('src')) .set('@assets',resolve('src/assets')) .set('styles',resolve('src/assets/styles')) // 这里只写了两个个,你可以自己再加,按这种格式.set('', resolve('')) } }