时间:2021-04-24 09:33:30 | 栏目:vue | 点击:次
在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';
总结