更改尺寸时更新价格
Updating the price on changing the size
我想在 product.selected_size
更改后立即更新 span 中显示的价格。在这种情况下,产品是我的组件的计算 属性。
<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>
我想在 product.selected_size
更改后立即更新 span 中显示的价格。在这种情况下,产品是我的组件的计算 属性。
<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>