VUE3 如何自定义指令

49 阅读1分钟

文本输入框的例子

定义全局自定义指令

app.directive('facus',{ mounted(el){ el.value = '这是一个自定义指令' console.log(el) } })

el 就是 input

局部自定义指令 directives:{ focus2:{ mounted(el){ el.value = 2222 } } }

自定义指令的参数

image.png