vuecli4 给路径取别名

1. 创建vue.config.js文件

2. 

const path = require('path')
const resolve = dir => path.join(__dirname, dir)

module.exports = {
  chainWebpack: config => {
    // 设置快捷路径, @ 表示 'src' ,components 表示 'src/components'
    config.resolve.alias
      .set('@', resolve('src'))
      .set('assets', resolve('src/assets'))
      .set('components', resolve('src/components'))
      .set('views', resolve('src/views'))
  },
}

 

posted @ 2020-05-24 19:15  必慎  阅读(1592)  评论(0编辑  收藏  举报