var util = require('../../utils/accounting.min.js'); Component({ properties: { symbol: { type: String, value: '', observer: 'updata' }, value: { type: Number, observer: 'updata' } }, data: { price: '' }, ready: function (options) { this.updata() }, methods: { updata () { var amount = Number(this.data.value) if (isNaN(amount)) { amount = 0 } var val = util.formatMoney(amount / 100, this.data.symbol, 2) this.setData({ price: val }) } } })