官术网_书友最值得收藏!

Format balance

Before we move on to filtering the users, add a method to correctly format the balance, prepending a currency symbol defined in the data object and ensuring there are two numbers after the decimal point. We can adapt our method from Chapter 1Getting Started with Vue.js,  to achieve this. Our Vue application should now look like this:

      const app = new Vue({
el: '#app',

data: {
people: [...],
currency: '$'
},
methods: {
activeStatus(person) {
return (person.isActive) ? 'Active' : 'Inactive';
},
formatBalance(balance) {
return this.currency + balance.toFixed(2);
}
}
});

We can utilize this new method in our View:

      <td>{{ formatBalance(person.balance) }}</td>
主站蜘蛛池模板: 六安市| 江城| 秦皇岛市| 开阳县| 天峨县| 高要市| 谷城县| 盐山县| 吐鲁番市| 滨海县| 合江县| 正宁县| 长泰县| 利川市| 巫山县| 遂溪县| 外汇| 通渭县| 舟山市| 彰化市| 枞阳县| 凤山县| 乐至县| 雷波县| 黄大仙区| 和田县| 武邑县| 陇川县| 吕梁市| 上栗县| 建水县| 聂拉木县| 虹口区| 清涧县| 大田县| 商都县| 资中县| 无为县| 沁水县| 潼关县| 沐川县|