Vue.js

一、特点

(1)渐进式

低侵入性,主张少

(2)组件化

(3)数据驱动

二、响应性原理

Object.defineProperty作为属性拦截器,Observer负责做数据层面的响应式及依赖收集,而Directive即compiler模块下的部分,负责做指令解析和DOM渲染。

三、生命周期

1 beforeCreate(创建前)
2 created(创建后)
3 beforeMount(载入前)
4 mounted(载入后)
5 beforeUpdate(更新前)
6 updated(更新后)
7 beforeDestroy(销毁前)
8 destroyed(销毁后)

四、v-指令

v-model

用在表单控件上的,用于实现双向数据绑定。

五、案例

//修改文本的值
<html>
<body>
<div id="app">
<p>{{ message }}</p>
<button v-on:click="update">修改</button>
</div>
<script>
new Vue({
el: '#app',
data: {
message: '陈小波'
},
methods:{
update:function(){ 
this.message="Chen Xiaobo";
}
}
})
</script>
</body>
</html>

 

posted @ 2018-08-05 16:25  cxbit  阅读(78)  评论(0编辑  收藏  举报