vue--过滤器

js代码:
/**
 * Created by luoxy on 2018/5/27.
 */
Vue.filter("currency",function(val,unti){
     val = val || 0;
     unti = unti || "元";
     return val + unti;
})
Vue.filter("len",function(val,m){
    return val/1000 +m;
})
new Vue({
    el:"#app",
    data:{
        price:10,
        length:15
    }
})


html代码:
< div id= "app" > < input type= "text" v-model= "price" > {{price|currency("USD")}} < hr /> < input type= "text" v-model= "length" > {{length | len("m")}} </ div >

猜你喜欢

转载自blog.csdn.net/qq_39111062/article/details/80471056
今日推荐