在react中应用react-mobx的状况下,数据曾经被action 扭转了,然而视图层 没有随之概念
如果mobx的版本大于6
"mobx": "^6.3.2","mobx-react": "^7.2.0"
切记增加 makeObservable 初始化我的项目
import { observable, action, computed, makeObservable } from "mobx";export class AuthStore { @observable name = 'wangkai000'; @observable sex = '男'; @observable userObj = { name: 'wangkai000', age: 233, token: '12345689' } constructor() { // makeObservable 在mobx6 版本之后 比增加项 makeObservable(this); } @action.bound setName(v) { console.log('触发action'); this.name = v; } @computed get titleName(){ return this.name+'___111'; } }