不想降级的同学参考这里
改动如下
import Vue from 'vue'
import Vuex from 'vuex'
import geo from './modules/geo'
Vue.use(Vuex)
export const modules = {
geo
}
export const actions = {
async nuxtServerInit({ commit }, { req, app }) {
const { status, data: { province, city } } = await app.$axios.get('/geo/getPosition')
commit('geo/setPosition', status === 200 ? { city, province } : { city: '', province: '' })
}
}