在webpack.base.conf文件中配置别名以及扩展名
resolve: { extensions: [‘.js‘, ‘.vue‘, ‘.json‘, ‘.styl‘], alias: { ‘vue$‘: ‘vue/dist/vue.esm.js‘, ‘@‘: resolve(‘src‘), ‘src‘: path.resolve(__dirname, ‘../src‘), ‘common‘: path.resolve(__dirname, ‘../src/common‘), ‘components‘: path.resolve(__dirname, ‘../src/components‘) } } 配置好别名和扩展名后,main.js就可以这样写
import Vue from ‘vue‘; import App from ‘./App‘; import Router from ‘vue-router‘; //components前面可以加上‘@/‘,也可以省略不写 //如果没有别名,就要写成“import goods from ‘../components/goods/goods‘;“ import goods from ‘components/goods/goods‘; import seller from ‘components/seller/seller‘; import ratings from ‘components/ratings/ratings‘; import ‘@/common/stylus/index‘;
原文地址:https://www.cnblogs.com/warter00774/p/8330124.html
时间: 2024-10-01 18:55:23