我正试图像这样访问过滤函数中的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
.