// two.js
export default { bind(el, binding, vnode){ console.log(binding); el.value = binding.value if (/\.async/.test(binding.rawName)) { el.onchange = handleFn; } else { el.oninput = handleFn; } function handleFn(e){ console.log(binding, e); vnode.context[binding.expression] = e.target.value; } }, update(el,binding){ console.log(binding); el.value = binding.value }, }
上面定义了一个指令 ,然后注册到VUE
<template> <input v-two="msg"> </template> <script> import two from './two' Vue.directive(‘two’, two); export default { data(){ return {msg: '1'} } } </script>
标签:el,console,log,自定义,binding,two,value,指令,model From: https://www.cnblogs.com/ehuanrum/p/17492055.html