Nuxt突变不会改变状态

时间:2020-01-26 09:37:00

标签: javascript vuex nuxt.js

这是我的商店: store / index.js

import { of, merge, BehaviorSubject } from 'rxjs'; 
import { switchMap } from 'rxjs/operators';

const s = new BehaviorSubject([of(1), of(2), of(3)]);

s.pipe(
  switchMap(array => merge(...array)),
).subscribe(x => console.log(x));

s.next([...s.getValue(), of(4)]);

问题是export const state = () => ({ userLocation: {} }) export const mutations = { setUserLocation(state, payload) { state.userLocation = payload console.log(payload) } } export const actions = { async fetchUserLocation({ commit }) { const { data } = await this.$axios.get( `${process.env.IPGEO_URL}?apiKey=${process.env.IPGEO_TOKEN}` ) commit('setUserLocation', data) } } 突变不会改变setUserLocation状态,并且不会更新。

但是当我登录时,我得到的结果是终端。 enter image description here

0 个答案:

没有答案