我想让a+b>5的时候,给p标签一个big类,我使用了过滤器,但是报错了.
请问这是为什么,有什么其他解决方法吗?
[Vue warn]: Invalid expression. Generated function body: {'big':scope.item
warn @ vue.js:1023
3vue.js:1023 [Vue warn]: Failed to resolve filter: isBig
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://cdn.bootcss.com/vue/1.0.26/vue.js"></script>
<style type="text/css">
.big{
background: gray;
}
</style>
</head>
<body>
<div id="saiku">
<p v-for="item in list" class="{'big': item | isBig item.a item.b}">{{item.name}}</p>
</div>
<script type="text/javascript">
'use strict';
var vm = new Vue({
el: '#saiku',
data: {
list:[
{a:1, b:2, name: 'aaa'},
{a:11, b:2, name: 'bbb'},
{a:1, b:2, name: 'ccc'}
]
}
});
Vue.filter('isBig', function(v,a,b){
if(a+b > 5){
return true;
}
else{
return false;
}
});
</script>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…