vue 配置全局 路径

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

module.exports = {
  devServer: {
    port: 8400,
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('assets', resolve('src/assets'))
    config.resolve.alias
      .set('components', resolve('src/components'))
  }
}

用法:

import headTitle from "@/components/common/headTitle.vue";

 

你可能感兴趣的:(前端vue技术点干货分享,全局配置)