实战使用场景,商城支付有港币,人民币,美元。根据用户的信息,设置币种的符号,在页面获取币种的符号。
let currencySymbol = { currency: '¥', get: function() { return this.currency }, set: function(currency) { this.currency = currency } } console.log(currencySymbol.get()) currencySymbol.set('%') console.log(currencySymbol)