我想要像这样访问vue实例数据内部的过滤器函数。 JS: -访问vue实例/数据里面的过滤器方法
new Vue({
data:{
amount: 10,
exchangeRate:50
},
el:"#app",
filters:{
currency: function(amount){
console.log(this);
//return amount * this.exchangeRate;
return amount *50;
}
}
})
HTML:
<div id="app">
{{ amount | currency}}
</div>
我的目标是使用return amount * this.exchangeRate;
但this
等于window
这里。 我该怎么做? 谢谢。 jsfiddle