【发布时间】:2017-08-07 07:23:14
【问题描述】:
我正在尝试像这样访问过滤器函数中的 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;
}
}
})
HTML:
<div id="app">
{{ amount | currency}}
</div>
我的目标是使用return amount * this.exchangeRate;,但这里this 等于window。
我怎样才能做到这一点 ?
谢谢。
jsfiddle
【问题讨论】:
标签: javascript vue.js vuejs2