//引用Vuex
|
|
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
import i18n from '@/locale/index.js'
|
|
Vue.use(Vuex)
|
|
|
|
import request from '@/utils/request.js'
|
|
|
|
//实例store对象
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
unit : '$',
|
|
key : {
|
|
'ar' : 'keyA', //阿拉伯
|
|
'en' : 'keyEnglish', //英语
|
|
'es' : 'keySpanish', //西班牙
|
|
'fr' : 'keyF', //法语
|
|
'ru' : 'keyE' //俄语
|
|
},
|
|
},
|
|
mutations: {
|
|
getUnit(state){
|
|
request('getUnit').then(res => {
|
|
if(res.code == 200){
|
|
state.unit = res.result[state.key[i18n.locale]]
|
|
}
|
|
})
|
|
},
|
|
}
|
|
})
|
|
|
|
//导出store对象
|
|
export default store
|
|
|
|
//export default const store或者export const store会报错
|