Vue. js achieves price formatting and vue. js prices formatting
Here we will share a common price formatting method which is very practical in e-commerce price processing. We can see an effect.
Here, a filter is used for the price data, which is used to retain the decimal places of the price.
HTML
<Div class = "price"> <span v-html = "goods. sale_price | format "> </span> <span class =" price-before ">¥ {" here is the price data "}}</span> </div>
JS
Filters: {// data filter format: function (value) {var html, _ val; value = Number (value ). toFixed (2); if (value = 0) {value = 0; return html = "¥ <span> 0 </span>";} else if (value. split ('. ') [1]. substring (1) = 0) {value = Number (value ). toFixed (1);} _ val = value. split ('. '); return html =' $ <span> '+ _ val [0] +' </span> <em>. '+ _ val [1] +' </em> ';}}
The above section describes how to format the price of vue. js. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!