前言
在新建的js文件中想用store里面的数据,比如token想在封装的axios里面,请求头里面去使用,亦或者通过app的JS接口获取token并存储在store里面。
我们都知道如何在vue中如何使用。
代码
/*
* @Description:
* @Author: lxc
* @Date: 2019-07-02 16:14:07
* @LastEditTime: 2019-08-14 16:08:19
* @LastEditors: lxc
*/
// 导出 store 的地方
import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import actions from './actions'
import mutations from './mutations'
import getters from './getters'
import canteen from './modules/canteen'
import contact from './modules/contact'
import health from './modules/health'
import scan from './modules/scan'
Vue.use(Vuex)
let store
const initStore = () =&