1. 程式人生 > >vue中的config配置

vue中的config配置

goods 別名 pre post ati import conf 文件中 dirname

在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‘;









vue中的config配置