| 在很多时候,你可能想在 mounted 和 updated 时触发相同行为,而不关心其它的钩子。比如这样写: 
 app.directive('pin', (el, binding) => {
 el.style.position = 'fixed'
 const s = binding.arg || 'top'
 el.style[s] = binding.value + 'px'
 })
 #对象字面量
 如果指令需要多个值,可以传入一个 JavaScript 对象字面量。记住,指令函数能够接受所有合法的 JavaScript 表达式。
 
 <div v-demo="{ color: 'white', text: 'hello!' }"></div>
 app.directive('demo', (el, binding) => {
 console.log(binding.value.color) // => "white"
 console.log(binding.value.text) // => "hello!"
 })
 |