我有下面的道具
props: ['applicants',],
我想使用props
,如下所示
methods : {
formated (item) {
var _self = this;
_self.values.length = 0;
if(item == "") {
console.log(this.applicants); //I am getting output here
_self.values = this.applicants
}
else {
console.log(this.applicants); //I am not getting output here
this.applicants.filter(applicant => { })
}
}
}
为什么会这样?
答案 0 :(得分:0)
您不需要创建对this
的引用。假设this.values
是一个数组:
methods: {
formatted (item) {
this.values = item == "" ? this.applicants : this.applicants.filter(applicant => { })
}
}