2017-04-13 116 views
2

我想在更改product.selected_size後立即更新跨度中顯示的價格。在這種情況下,產品是我的組件的計算屬性。在更改尺寸時更新價格

<div class="prices-wrapper"> 
<span class="price-normal">&euro; {{ product.prices[product.selected_size] }}</span> 
</div> 

回答

0

您可以使用新的計算屬性。

computed: { 
    price: function() { 
    return this.product.prices[this.product.selected_size] 
    } 
} 

<div class="prices-wrapper"> 
    <span class="price-normal">&euro; {{ price }}</span> 
</div>