goods 别名 pre post ati import conf 文件中 dirname
在 webpack.base.conf 文件中配置别名以及扩展名
resolve: {
extensions: ['.js', '.vue', '.json', '.styl'],
alias: {
'vue
配置好别名和扩展名后,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';
vue 中的 config 配置
: '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';
vue 中的 config 配置
来源: http://www.bubuko.com/infodetail-2470897.html