基础用法
<div id="app">
{{x | tese}}
</div>
复制代码
const app = new Vue({
el: '#app',
data: {
x:1
},
filters:{
tese(value){
return value == 0?'男':'女'
}
},
conponents: {},
methods: {},
mounted() {}
})
复制代码
传值法
<div id="app">
{{x | tese('人')}}
</div>
复制代码
const app = new Vue({
el: '#app',
data: {
x:1
},
filters:{
tese(value,params){
return (value == 0?'男':'女') + params
}
},
conponents: {},
methods: {},
mounted() {}
})
复制代码
还可以多次过滤
<div id="app">
{{x | tese('人') | test2}}
</div>
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END