對于單個對象,我可以使用computed通過計算獲得一些屬性,比如@observable good = { number: 2, price: 3}@computed get totalPrice() { return this.good.number * this.good.price;}對于數組,比如@observable goodsList = [{ number: 2, price: 3},{ number: 2, price: 3}]這種情況我如何通過computed獲得數組某個元素的計算屬性呢,還是只能在改變number的函數中手動去更改,但是我數組的對象中并沒有一個totalPrice的屬性,每次把單個good push到goodsList中去還要給good添加一個totalPrice屬性豈不是很麻煩
一個mobx中computed屬性的問題
一只名叫tom的貓
2018-12-11 11:22:51