自定义v-orange指令 Vue.directive('orange', { inserted: function(el) { console.log('el', el);//输出:<h1 v-orange>我是文本</h1> el.style.backgroundColor = "orange"; } }) var vm = new Vue({ el: "#app" });