我正在为我的加密货币购买自己的目录。Vue.js根变量
我通过API获取BTC,ETH和LTC的价格,然后我为每个打出的硬币创建了一个组件,然后我想计算当前价格(ownedCoins * currentPrice)。
所以在我的$根我有{乙:324.233,BTC:2211.43,LTC:41.341}
这里就是我想计算的话:
self.eur = response.data.sum[0].quantity * this.$root.ltc;
但我想使这个动态的,所以我想要做的是创建一个动态变量。类似的东西:self.eur = response.data.sum[0].quantity * this.$root.{this.coinName};
我该怎么做?
除了self.eur本身,哪个值应该在数据中动态变化? – Cobaltway
请注意'response.data.sum [0] .quantity * this。$ root。{this.coinName}'是无效的js。 'response.data.sum [0] .quantity * this。$ root [this.coinName]'is。 – Cobaltway