Home  >  Article  >  Web Front-end  >  Code implementation of custom filters in vue

Code implementation of custom filters in vue

不言
不言Original
2018-08-23 16:59:021357browse

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 &#39;@/util/filter&#39;
    import { mapState } from &#39;vuex&#39;
    import { Toast } from &#39;mint-ui&#39;

    export default {        // 支付页面
        name: &#39;partyDuesPay&#39;,
        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)

What are the value-passing methods of vue? Introduction to commonly used value-passing methods in vue (3 types)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn