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 = 0
setInterval(() => {
model.change({
speed: ++total
})
}, 3000)
export default model
2.computed里的console只被触发了一次
3.没看出来代码哪里的问题,求解
皈依舞
相关分类