增加项目成本页面
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
:key="index"
|
||||
>
|
||||
<view class="card-title">{{ card.title }}</view>
|
||||
<view class="card-value">人民币:{{ card.valueCNY }}</view>
|
||||
<view class="card-value">美元:{{ card.valueUSD }}</view>
|
||||
<view class="card-value">人民币:{{ formatNumber(card.valueCNY) }}</view>
|
||||
<view class="card-value">美元:{{ formatNumber(card.valueUSD) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -37,9 +37,9 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 格式化数字,添加千位分隔符
|
||||
formatNumber(num) {
|
||||
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
if (isNaN(num)) return '0'; // 兜底处理
|
||||
return num.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ','); // 保留2位小数+千位分隔符
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user