2
我想在更改product.selected_size
後立即更新跨度中顯示的價格。在這種情況下,產品是我的組件的計算屬性。在更改尺寸時更新價格
<div class="prices-wrapper">
<span class="price-normal">€ {{ product.prices[product.selected_size] }}</span>
</div>
我想在更改product.selected_size
後立即更新跨度中顯示的價格。在這種情況下,產品是我的組件的計算屬性。在更改尺寸時更新價格
<div class="prices-wrapper">
<span class="price-normal">€ {{ product.prices[product.selected_size] }}</span>
</div>
您可以使用新的計算屬性。
computed: {
price: function() {
return this.product.prices[this.product.selected_size]
}
}
和
<div class="prices-wrapper">
<span class="price-normal">€ {{ price }}</span>
</div>