Reputation: 315
I used Vue-Multiselect https://vue-multiselect.js.org/#sub-getting-started to create a multi select input as follows
<multiselect v-on:select="myfilter()" v-model="cityF"
:options="cities" placeholder="City" label="name" track-by="name">
</multiselect>
But this is always undefined inside myfilter function. What is the problem? How can i solve it ? Thanks in adavnce.
Upvotes: 0
Views: 92
Reputation: 35694
I'm only guessing, but...
This
instead of this
¯\_(ツ)_/¯This is easy to fix, just use 'this' instead of 'This'
methods:{
myfilter: function() {
console.log(this.whyNoWork);
}
}
this will not use the correct scope, instead use
methods:{
myfilter: function() {
console.log(this.isWorking);
}.bind(this)
}
or better yet
methods:{
myfilter() {
console.log(this.isWorking);
}
}
myfilter
instead of myfilter()
, unless you want to pass something to it<multiselect v-on:select="myfilter" v-model="cityF"
:options="cities" placeholder="City" label="name" track-by="name">
</multiselect>
also more code usually means more help, otherwise we're just guessing.
Upvotes: 2