自定义指令
// 自定义指令
Vue.directive('focus',{
bind(el,binding){
console.log(el,binding,'---------')
},
inserted(el){
el.focus()
console.log(el,'++++++++')
}
})
Vue.component('ComponentA',{
template:'<div><input type="text" v-focus /></div>'
})
var vm = new Vue({
el:"#app",
data:{
msg:'sxq'
},
template:'<div><ComponentA></ComponentA></div>'
})
发表回复