<view>{{ filters.toFix.parseFloat(goodsPrice) }}</view>
String.prototype.moneyFormat = function(returnArr){
parts = this.replace(’,’, ‘’).split(’.’)
parts[1] = (parts[1] = parts[1] || ‘00’) + (parts[1].length < 2 ? ‘0’ : ‘’)
return returnArr ? parts : parts.join(’.’)
}
Number.prototype.moneyFormat = function (returnArr) {
return this.toString().moneyFormat(returnArr)
}
var price = 50
price.moneyFormat() // => 50.00
price = 50.01
price.moneyFormat(1) // => [“50”, “01”]
price = ‘1,050.01’
parts = price.moneyFormat(1) // => [“1050”, “01”]
this.setData({
priceInt: parts[0],
priceFloat: parts[1]
})
WXSS
.price{
color: #ffb701;
font-size: 30px;
font-weight: 600;
}
sub{
font-size: 15px;
}
WXML
<view class=“price”><sub>¥</sub>{{priceInt}}<sub>.{{priceFloat}}</sub></view>