我试图在menuTags()方法中访问一个名为filterCurrent()的方法,但是vue抛出了一个它无法识别的错误。
我觉得这与范围有关。任何人都可以提供一些有关原因的见解吗?
methods: {
filterCurrent() {
var self = this;
// var results = this.results;
var activeTags = this.currentTags.tags;
//console.log(activeTags);
this.results.filter(function (result) {
// Reset current result to false;
result.active = false;
// Loop throigh current result tags
result.tags.some(function (tag) {
// Loop through activeTags
activeTags.filter(function (activeTag) {
// If one of the tags in the current result match any of the activeTag set it to active
if (tag.indexOf(activeTag) != -1) {
//console.log(activeTags);
result.active = true;
//console.log(activeTag);
}
})
})
}, this)
},
menuTags(label) {
//this.currentTags.push(label.tags);
//this.filterCurrent();
let self = this;
var passedTags = label.tags;
console.log(passedTags);
passedTags.filter(function(tag) {
this.currentTags.push(tag);
}, this)
this.filterCurrent();
}
},