浏览代码

Currency Format

master
Kobus 5 年前
父节点
当前提交
79da97396e
共有 2 个文件被更改,包括 13 次插入6 次删除
  1. 1
    6
      src/components/timeshare/buy/weekListComponent.vue
  2. 12
    0
      src/main.js

+ 1
- 6
src/components/timeshare/buy/weekListComponent.vue 查看文件

@@ -1,15 +1,12 @@
1 1
 <template>
2 2
   <div>
3
-    <button @click="addDummyWeek" class="btn btn-primary">Add Dummy</button>
4 3
     <table class="table table-bordered">
5 4
       <thead>
6 5
         <tr>
7 6
           <th>Resort</th>
8 7
           <th>Unit Number</th>
9 8
           <th>Week Number</th>
10
-          <th>Module</th>
11 9
           <th>Bedrooms</th>
12
-          <th>Season</th>
13 10
           <th>Price</th>
14 11
           <th>Status</th>
15 12
           <th>Interested</th>
@@ -20,10 +17,8 @@
20 17
           <td>{{item.resort.resortName}}</td>
21 18
           <td>{{item.unitNumber}}</td>
22 19
           <td>{{item.weekNumber}}</td>
23
-          <td>{{item.module}}</td>
24 20
           <td>{{item.bedrooms}}</td>
25
-          <td>{{item.season}}</td>
26
-          <td>{{item.sellPrice}}</td>
21
+          <td>{{item.sellPrice | toCurrency}}</td>
27 22
           <td>{{item.status ? item.status.description : ''}}</td>
28 23
           <td></td>
29 24
         </tr>

+ 12
- 0
src/main.js 查看文件

@@ -8,6 +8,18 @@ Vue.use(EvaIcons);
8 8
 
9 9
 Vue.config.productionTip = false;
10 10
 
11
+Vue.filter('toCurrency', (value) => {
12
+  if (typeof value !== 'number') {
13
+    return value;
14
+  }
15
+  const formatter = new Intl.NumberFormat('en-US', {
16
+    style: 'currency',
17
+    currency: 'ZAR',
18
+    minimumFractionDigits: 2,
19
+  });
20
+  return formatter.format(value);
21
+});
22
+
11 23
 new Vue({
12 24
   render: h => h(App),
13 25
   router,

正在加载...
取消
保存