<repo_name>hjj333/vue<file_sep>/src/store/mutation-types.js
// 使用常代替mutation事件类型
export const RECEIVE_ADDRESS = 'receive_address' // 接收地址
export const RECEIVE_CATEGORYS = 'receive_categorys' // 接收食品分类数组
export const RECEIVE_SHOPS = 'receive_shops' // 接收商家数组
export const RECEIVE_USERINFO = 'receive_userInfo' // 接收商家数组
export const RESET_USERINFO = 'reset_userInfo' // 重置用户信息
export const RECEIVE_GOODS = 'receive_goods'
export const RECEIVE_RATINGS = 'receive_ratings'
export const RECEIVE_INFO = 'receive_info'
export const INCREMENT_FOOD_COUNT = 'increment_food_count' // 增加food中的count值
export const DECREMENT_FOOD_COUNT = 'decrement_food_count'
export const CLEAR_CART = 'clear_cart' // 清空购物车
export const RECEIVE_SEARCHSHOPS = 'receive_searchshops' // 搜索商家列表
<file_sep>/src/main.js
import Vue from 'vue'
import moment from 'moment'
import { Button } from 'mint-ui'
import VueLazyload from 'vue-lazyload'
import loading from '../src/assets/images/loading.gif'
import App from './App.vue'
import router from './router'
import store from './store/index'
import './mock/mockServer'
// 自定义过滤器使用日期格式
Vue.filter('date-format', function (value) {
  return moment(value).format('YYYY-MM-DD HH-mm-ss')
})
// 注册全局组件标签<mt-button>
Vue.component(Button.name, Button)
// 使用图片懒加载插件
Vue.use(VueLazyload, {
  loading
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
<file_sep>/vue.config.js
module.exports = {
  chainWebpack: config => {
    // 修复HMR
    config.resolve.symlinks(true)
  },
  devServer: {
    proxy: {
      // 匹配所有以'/api'开头的请求路径
      '/api': {
        target: 'http://localhost:4000',  //对应后台服务器接口
        changeOrigin: true,               //允许跨域
        ws: true,
        pathRewrite: {                   //重写路径：去掉路径中开头的'/api'
          '^/api': ''
        }
      }
    }
  }
}
