new Vue() -----> 设置数据data -----> 挂载元素 ----- > 成功渲染
复制代码
代码:javascript
<body>
<div id="app">
{{ message }}
</div>
</body>
<script type="text/javascript" src="js/vue.min.js"></script>
<script> new Vue({ el:'#app', data:{ message:'hello' } }) </script>
复制代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>自定义指令</title>
<meta name="description" content="">
<meta name="keywords" content="">
</head>
<body>
<p v-tack class='p'>
I will now be tacked noto the page
<input v-focus type='text'>
<input v-border type='text'>
</p>
</body>
<script type="text/javascript" src='js/vue.min.js'></script>
<script type="text/javascript"> // 自定义全局指令 Vue.directive('border',{ bind(el){ el.style.border='1px red solid' } }) new Vue({ el:'.p', //自定义局部指令 directives:{ tack:{ inserted(el){ el.style.color='red' } }, focus: { // 指令的定义 inserted: function (el) { el.focus() } } } }) </script>
</html>
复制代码
Vue.component('myarticl',{
props:[],
template:'',
render:function(){},
data:function(){},
computed:{},
components:{},
methods:{}
watch:{},
mounted:{},
filters:{}
})
复制代码
new Vue({
//实例挂载目标
el:'#app',
//设置数据对象
data:{
},
//计算属性
computed:{
},
//方法
methods:{
}
//监听 观察
watch:{
},
//生命周期钩子函数
mounted:{
},
//自定义局部组件
directives:{
},
//局部注册组件
components:{
}
//过滤器
fillters:{
}
})
复制代码