[MobX] Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: UserStore@12.userInfo
找到出错位置如:UserStore@12.userInfo
将下面代码
async getUserInfo () {
// 调用接口获取数据
const res = await http.get('/user/profile')
this.userInfo = res.data
console.log("UserStore:",this.useInfo )
}
引入import { makeAutoObservable, runInAction } from "mobx";
将上面代码修改为
async getUserInfo () {
// 调用接口获取数据
const res = await http.get('/user/profile')
runInAction(() => {
this.userInfo = res.data
})
console.log("UserStore:",this.userInfo )
}