1.使用mobx里的computed无法生效class ODOM { constructor(props) { console.log('how many times') } @observable speed = 0 @action change(obj) { console.log(obj) Object.keys(obj).forEach(item => { this[item] = obj[item] }) } @computed get velocity() { console.log('entry') return this.speed*60*60/1000 }}const model = new ODOM()let total = 0setInterval(() => { model.change({ speed: ++total })}, 3000)export default model2.computed里的console只被触发了一次3.没看出来代码哪里的问题,求解
添加回答
举报
0/150
提交
取消