Home > Web Front-end > JS Tutorial > body text

Code implementation of custom filters in vue

不言
Release: 2018-08-23 16:59:02
Original
1406 people have browsed it

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)
}
Copy after login

**.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>
Copy after login

template

<div class="moneyAmount"><span>¥</span>{{partyInfo.totalPayAmt | fen_yuan}}</div>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!