Vue.directive('selecttwo', {
params: ['taskId'],
bind: function () {
var self = this;
$(this.el)
.select2()
.on('change', function () {
self.set(this.value);
if (!this.name.match(/[a-z]/i)) {
console.log('task-id->'+self.params.taskId); // task-id->undefined
}
})
},
});
How can I get the params.taskId
on onchange
event? I already tried this.params.taskId
, but I still get undefined.
Maybe you can paste your html code,that will help to find issue.
I guess your html attribute name is incorrect,in vue,js use "camelCase", but html use "kebab-case",try like this:
<span task-id="i am id" v-selecttwo >
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.