Vue.directive('focusNext', {
bind: function () {
this.handler = function () {
if (this.el.value.length >= this.expression) {
var next = this.el.nextSibling;
next.focus();
}
}.bind(this)
this.el.addEventListener('input', this.handler)
},
unbind: function () {
this.el.removeEventListener('input', this.handler)
}
})
var vm = new Vue({
el: '# demo',
})
关键字:vue.js, vue, directive, focus