我正在尝试像这样访问过滤器函数中的vue实例数据.JS: -
new Vue({
data:{
amount: 10,
exchangeRate:50
},
el:"#app",
filters:{
currency: function(amount){
console.log(this);
//return amount * this.exchangeRate;
return amount *50;
}
}
})
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="app">
{{ amount | currency}}
</div>
Run Code Online (Sandbox Code Playgroud)
我的目标是使用,return amount * this.exchangeRate;
但this
在window
这里等于.我怎样才能做到这一点 ?谢谢.
的jsfiddle