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

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>
主站蜘蛛池模板: 洛川县| 石楼县| 淮北市| 罗源县| 梁平县| 新沂市| 东兰县| 湘西| 泰兴市| 闽清县| 岳西县| 西丰县| 繁昌县| 阳高县| 西贡区| 吉木乃县| 定南县| 桐城市| 喀喇沁旗| 喀喇沁旗| 涞水县| 大埔区| 武鸣县| 鄂州市| 鄂州市| 布尔津县| 大新县| 庐江县| 垣曲县| 涟源市| 保靖县| 凤山市| 莆田市| 林周县| 桓台县| 中西区| 谢通门县| 台山市| 香港| 阿城市| 鸡泽县|