ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] #### 1.自定义指令详解directive 官方文档:https://cn.vuejs.org/v2/guide/custom-directive.html <div id="hdcms"> <span v-star="color">标题</span> <input type="text" v-model="color" v-focus> <h1 v-hide="false">hdphp</h1> </div> <script> new Vue({ el: '#hdcms', data: { title: 'houdunren.com', color: 'red' }, directives: { star(el, bind){ var color = bind.value ? bind.value : 'red'; el.style.cssText = "color:" + color; }, //bind update focus: { inserted(el, bind){ el.focus(); } }, hide(el, bind){ console.log(bind); if (bind.value) { el.style.cssText = "display:none"; } } } }); </script>