vuejs生存周期
<script type="text/javascript">
var vm=new vue({
el:'',
data:{
},
created:function(){
alert('实例已经创建');
},
beforeCompile:function(){
alert('编译之前');
},
compiled:function(){
alert('编辑之后');
},
ready:function(){
alert('文本插入到文档中');
},
beforeDestroy:function(){
},
destroyed:function(){
},
computed:{ //b是计算属性值 不是函数 返回值return的是b的值 可以用在{{}}中
b:function(){ //默认调用get方法
return 2;
}
b:{
get:function(){
return 2;
},
set:function(){
return 2;
}
}
},
methods:{
add:function(){
this.$http({
url:'',
method:'get/post/jsonpsssssss',
data:{ //ajax请求发送的数据
act:'',
content:''
},
}).then(function(res){
//这里讲返回数据写入data中
this.myData.unshift();
})
},
}
})
document.click(
vm.$destory();
)
</script>
- 防止闪烁 v-cloak 在div中加入v-cloak
- [v-clock]{ display:display }
- v-text v-html 防止闪烁
- 计算属性的使用
- vue实例vm中的一写小方法
vm. datavm. el vm. destory()vm. mount(‘#box’)手动挂载 vm.$options自定义属性