Your v-if
condition is not in the appropriate tag. It should be in the span
of discount. Working demo below:
new Vue({
el: '#app',
data() {
return {
original_price: 10,
discount_price: 20
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id='app'>
<span class="price-info mr-2">
{{ original_price | numeral('0,0') }}
</span>
<span v-if="original_price > discount_price">
{{ Number((original_price - discount_price) / original_price) * 100 + '%' }}
</span>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…