{{ msg | capitalize }}
// 'abc' => 'ABC'
<ul class="product">
<li v-for="product in products|filterBy '水果' in 'category' |orderBy 'price' 1">
{{product.name}}-{{product.price | currency}}
</li>
</ul>
Vue.filter() Constructor Parameters:
Vue.filter('discount', function(value) {
return value * .5;
});
var product = new Vue({
el: '.product',
data: {
products: [
{name: '苹果',price: 25,category: "水果"},
{name: '香蕉',price: 15,category: "水果"},
{name: '雪梨',price: 65,category: "水果"},
{name: '宝马',price: 2500,category: "汽车"},
{name: '奔驰',price: 10025,category: "汽车"},
{name: '柑橘',price: 15,category: "水果"},
{name: '奥迪',price: 25,category: "汽车"}
]
},
})
<ul class="product">
<li v-for="product in products|filterBy '水果' in 'category' |orderBy 'price' 0">
{{product.name}}-{{product.price|discount | currency}}
</li>
</ul>
Vue.filter('discount', function(value, discount) {
return value * (discount / 100);
});
<ul class="product">
<li v-for="product in products|filterBy '水果' in 'category' |orderBy 'price' 0">
{{product.name}}-{{product.price|discount 25 | currency}}
</li>
</ul>
/*定义在全局
Vue.filter('discount', function(value,discount) {
return value * ( discount / 100 ) ;
});
*/
var product = new Vue({
el: '.product',
data: {
products: [
{name: '苹果',price: 25,category: "水果"},
{name: '香蕉',price: 15,category: "水果"},
{name: '雪梨',price: 65,category: "水果"},
{name: '宝马',price: 2500,category: "汽车"},
{name: '奔驰',price: 10025,category: "汽车"},
{name: '柑橘',price: 15,category: "水果"},
{name: '奥迪',price: 25,category: "汽车"}
]
},
//自定义在实例
filters: {
discount: function(value, discount) {
return value * (discount / 100);
}
}
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有