content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
Document{{message}}
// Object.defineProperties() 创建里面有get 和set 方法
let testVale = new Vue({
el: "#app",
// template:"
111
",
data: {
message: "3年工作经验,找工作",
IntervalId:null
},
methods: {
lang() {
this.IntervalId=setInterval(()=>
{
let beginStr = this.message.substring(0, 1);
let endStr = this.message.substring(1);
this.message = endStr + beginStr;
},400)
},
remove(){
clearInterval(this.IntervalId)
}
},
//1 这个Object.defineProperties() 创建状态的 beforeCreate() 时候,会去调用这个函数,用get
// set 方法 去双向连接 data的值发生改变 view的值也会发生改变
// beforeCreate Create
//2 走ajax了 数据回调了,
// 下一步执行的时候 ,去走 有没有mount 属性,vm.$Mount() 去判断有没有模板 有走模板 没有不走
// 组件走模板
// mount 嵌入
//3 beforeMount mount 这一步其实在填充数据 ,去判断有没有模板
// 如果有的话,会把模板的内容挂载到页面,如果没有 就把el 元素的内容填充上去
//当走到mount 的时候,这个地方也可以写ajax 了,和上面的create 是一样的
// 但是有个区别,这个地方已经加载上dom 元素了,而在上面还没加载出来,如果实在没办法,这个地方可以用
//document.getElementByID () 等
// 当以上都加载完成,然后cteateUpdate update 表示上面的填充步骤完成了
// 其实在以上的步骤都没触发的时候,可以直接进行数据修改,也会对数据进行渲染(例如 页面直接测试)
// 这个生命周期,最主要的是 缓存机制,最后一口气把缓存的数据 一直刷新到页面上去
// 最后要进行过资源释放也就是销毁
//BeforeDestroy destroy
beforeCreate: function () {
/* console.group('beforeCreate 创建前状态===============》');
console.log("%c%s", "color:red", "el : " + this.$el); //undefined
console.log("%c%s", "color:red", "data : " + this.$data); //undefined
console.log("%c%s", "color:red", "message: " + this.message)*/
},
//创建状态完成
created: function () {
/* console.group('created 创建完毕状态===============》');
console.log("%c%s", "color:red", "message: " + this.message); //已被初始化*/
},
//挂载状态完成
beforeMount: function () {
/* console.group('beforeMount 挂载前状态===============》');
console.log("%c%s", "color:red", "el : " + (this.$el)); //已被初始化
console.log(this.$el);
console.log("%c%s", "color:red", "data : " + this.$data); //已被初始化
console.log("%c%s", "color:red", "message: " + this.message); //已被初始化*/
},
//挂载结束
mounted: function () {
debugger;
//这个ref 就相当于map 集合里面的 key 是个集合 而且属性是一个集合
alert(this.$refs.lang)
/* console.log("%c%s", "color:red", "message: " + this.message); //已被初始化*/
},
//beforeUpdate 更新前状态
beforeUpdate: function () {
/* console.log("%c%s", "color:red", "message: " + this.message);*/
},
//updated 更新完成状态
updated: function () {
/* console.log("%c%s", "color:red", "message: " + this.message);*/
},
//销毁前状态完成
beforeDestroy: function () {
/* console.log("%c%s", "color:red", "message: " + this.message);*/
},
//销毁状态完成
destroyed: function () {
/* console.log("%c%s", "color:red", "message: " + this.message)*/
}
})
一键复制
编辑
Web IDE
原始数据
按行查看
历史