全局指令参数形式
main.js
Vue.config.productionTip = false
// app.directive('focus',{
// mounted(el){
// el.focus()
// },
// updated(el){
// el.focus()
// }
// })
app.directive('focus',(el)=>{
el.focus()
})
app.directive('color',(el,binding)=>{
el.style.color= binding.value
})
组件内
<template>
<div class="home-container">
<h3 v-color="'red'">MyHome组件---{{count}}</h3>
<input type="text" v-model.number="count" v-focus v-color="'red'">
<p v-color="'cyan'">{{count}}</p>
<button @click="count++"></button>
</div>
</template>