VUE生命周期demo
<!DOCTYPE html>
<html><head> <title></title> <script type="text/javascript" src="https://cdn.jsdelivr.net/vue/2.1.3/vue.js"></script></head><body> <div id="app"> <p>{{ message }}</p> <button @click="btn">改变按钮</button> </div> <script type="text/javascript"> var app = new Vue({ el: '#app', data: { message: "xuxiao is boy" }, 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) //undefined }, created: function() { console.group('created 创建完毕状态===============》'); console.log("%c%s", "color:red", "el : " + this.$el); //undefined console.log("%c%s", "color:red", "data : " + this.$data); //已被初始化 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() { console.group('mounted 挂载结束状态===============》'); 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); //已被初始化 }, beforeUpdate: function() { console.group('beforeUpdate 更新前状态===============》'); 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); }, updated: function() { console.group('updated 更新完成状态===============》'); 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); }, beforeDestroy: function() { console.group('beforeDestroy 销毁前状态===============》'); 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); }, destroyed: function() { console.group('destroyed 销毁完成状态===============》'); 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) }, methods: { btn: function() { this.message = "change" } } }) </script></body></html>VUE生命周期demo的更多相关文章
- 【Vue笔记】-- 详解vue生命周期
针对于Vue的生命周期进行详细的说明,方面加深对各个方法的引用. 引言: 前几天重新回顾vue官网时,看到vue的生命周期,想着自己用vue开发了快一年了,就总结总结vue知识,再次加深自己对vue的 ...
- Vue生命周期钩子---3
vue生命周期流程图:4张图 : 生命周期的解析和应用: Vue 实例有一个完整的生命周期,也就是从开始创建.初始化数据.编译模板.挂载Dom→渲染.更新→渲染.卸载等一系列过程,我们称这是 Vue ...
- vue 生命周期的详解
一.vue生命周期的解析 > 1>什么是vue生命周期 每个vue实例在被创建之前都要经过一系列的初始化过程,这个过程就是vue的生命周期.详细来说,就是Vue实例从开始创建,初始化数据, ...
- vue生命周期的介绍
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- vue 生命周期
一 vue的生命周期如下图所示(很清晰) 二 vue生命周期的栗子 注意触发vue的created事件以后,this便指向vue实例,这点很重要 <!DOCTYPE html> <h ...
- 详解vue生命周期
vue生命周期 @(vue)[生命周期] 前言 在使用vue一个多礼拜后,感觉现在还停留在初级阶段,虽然知道怎么和后端做数据交互,但是对于mounted这个挂载还不是很清楚的.放大之,对vue的生命周 ...
- 关于vue生命周期
官网给出的实例的生命周期图如下: beforeCreate(页面创建前),created(页面创建后),beforeMount(页面载入前),mounted(页面载入后),beforeUpdate(页 ...
- vue生命周期的理解
我从官网上下载了一张vue生命周期的图,接下来实际分析一波vue到底执行了什么东西. 1.我们在使用vue时必不可少的操作就是 var vm = new Vue({}),这样我们就创建了一个vue的实 ...
- Vue生命周期,面试常见问题
一.对于MVVM的理解? MVVM 是 Model-View-ViewModel 的缩写.Model代表数据模型,也可以在Model中定义数据修改和操作的业务逻辑.View 代表UI 组件,它负责将数 ...
随机推荐
- [转载] Java注解
目录 元注解 @Retention @Documented @Target @Inherited @Repeatable 注解语法 ---------------------------------- ...
- openlayers之天地图为底图 叠加其他底图 加载遇到的各种报错
今天以前使用天地图为底图时,map里source的定义:http://t3.tianditu.com~~~ 今天突然报跨域的错误,原有地址访问受限,可是key值是有的 最后发现就是前半段的原因 将前半 ...
- 一、Nginx多站点配置
一.下载 目录文件: 二.运行方式 (1)直接双击nginx.exe,双击后一个黑色的弹窗一闪而过 (2)打开cmd命令窗口,切换到nginx解压目录下,输入命令 nginx.exe 或者 start ...
- Hive Server2(五)
HiveServer2 基本概念介绍 1.HiveServer2基本介绍 HiveServer2 (HS2) is a server interface that enables remote cli ...
- orace result cache解析
(1) orace 11.2.0.4 在RAC数据库Dataguard切换时,出现少量数据丢失: 解决方案:关闭result cache 功能 或升级数据库版本并安装补丁: ...
- hive建表结构
drop table dw.fct_so;create table dw.fct_so(so_id bigint comment '订单ID',parent_so_id bigint comment ...
- ibatis与mybatis的区别
一.最主要的区别就是mybatis简化了编码的过程,不需要去写dao的实现类,直接写一个dao的借口,再写一个xml配置文件,整个mybatis就配置好了,也就是数据库就连接好了,然后再service ...
- msvsmon.exe xp下不能运行
远程调试 xp 下不能执行 vs2013 远程调试器 xp下不能运行 vs2010 远程调试器 xp下可以运行
- 关于 Vue 微信客户端 不能播放音乐(报错和不能播放的问题)
前言 用vue 做音乐播放的时候,在本地可以打开播放,但在微信里面不能播放音乐 所以这样解决 // 音乐播放 audioPlay(){ let _this = this; var audio = _t ...
- sys.argv的意义及用法
sys.argv的意义 简单来说,sys.argv是一个参数列表,这个列表存放着从外界获取到的参数(可能有多个) 下面以一个例子来详细阐述sys.argv,本次演示在ubuntu环境下运行 新建一个t ...