欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
在实例使用 directives 选项来注册局部指令,这样指令只能在这个实例中使用:
 
实例
<div id="app">
    <p>页面载入时,input 元素自动获取焦点:</p>
    <input v-focus>
</div>
 
<script>
const app = {
   data() {
      return {
      }
   },
   directives: {
      focus: {
         // 指令的定义
         mounted(el) {
            el.focus()
         }
      }
   }
}
 
Vue.createApp(app).mount('#app')

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h65187.shtml