v-text
v-for
v-html
指令: 扩展html语法
自定义指令:
1. 自定义属性指令:
Vue.directive(指令名称,function(参数){ this.el -> 原生DOM元素 // vm.$el }); <div v-red="参数"></div>
指令名称: v-red -> red
* 注意: 必须以 v-开头(定义时去掉v-)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>智能社——http://www.zhinengshe.com</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <style> </style> <script src="vue.js"></script> <script> Vue.directive('red',function(color){ this.el.style.background=color; }); window.onload=function(){ var vm=new Vue({ el:'#box', data:{ a:'blue' } }); }; </script> </head> <body> <div id="box"> <span v-red="a"> asdfasd </span> </div> </body> </html>