The content of this article is about the code implementation of custom filters in vue. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Not much to say, just go to the code
Create a new filter.js file such as:
// 金额 分 --> 元 exports.fen_yuan = (value) => { let tmp = Number(value) || 0 // tmp = parseInt(tmp, 10); tmp /= 100 return tmp.toFixed(2) }
**.vue file
<script> import * as filter from '@/util/filter' import { mapState } from 'vuex' import { Toast } from 'mint-ui' export default { // 支付页面 name: 'partyDuesPay', filters: filter, data() { return {} } } </script>
template
<div class="moneyAmount"><span>¥</span>{{partyInfo.totalPayAmt | fen_yuan}}</div>
Related recommendations:
Introduction to the use of store in vuex (with examples)
The above is the detailed content of Code implementation of custom filters in vue. For more information, please follow other related articles on the PHP Chinese website!