当前位置: 首页 > news >正文

唐山网站建设优化方法免费申请微信收款码

唐山网站建设优化方法,免费申请微信收款码,wordpress 怎么安装主题,洪梅网站建设公司目录 一、引出生命周期 二、生命周期_挂载流程 三、生命周期_更新流程 四、生命周期_销毁流程 五、生命周期_总结 一、引出生命周期 生命周期#xff1a; 1.又名#xff1a;生命周期回调函数、生命周期函数、生命周期钩子。 2.是什么#xff1a;Vue在关键时刻帮我们调…目录 一、引出生命周期 二、生命周期_挂载流程 三、生命周期_更新流程 四、生命周期_销毁流程 五、生命周期_总结 一、引出生命周期 生命周期 1.又名生命周期回调函数、生命周期函数、生命周期钩子。 2.是什么Vue在关键时刻帮我们调用的一些特殊名称的函数。 3.生命周期函数的名字不可更改但函数的具体内容是程序员根据需求编写的。 4.生命周期函数中的this 指向是vm 或 组件实例对象。 Vue完成模板的解析并把初始的真实的DOM元素放入页面后挂载完毕调用mounted !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgetitledocument/titlescript srchttps://cdn.jsdelivr.net/npm/vue2/dist/vue.js/script /head body div idrooth2 v-ifa你好啊/h2!-- {opacity}为{opacity: opacity}的简写形式第一个opacity为属性第二个为属性值 --h2 :style{opacity}欢迎学习Vue/h2!-- {{change()}} --/divscript typetext/javascript Vue.config.productionTip falseconst vm new Vue({el:#root,data:{opacity:1,a:false,},methods:{/* change(){setInterval((){this.opacity - 0.01if(this.opacity 0) this.opacity 1},16)}, */},// Vue完成模板的解析并把初始的真实的DOM元素放入页面后(挂载完毕)调用mountedmounted() {console.log(mounted,this);//此处的this是vue实例setInterval((){vm.opacity - 0.01if(vm.opacity 0) vm.opacity 1},16)}, })// 通过外部的定时器实现不推荐/* setInterval((){vm.opacity - 0.01if(vm.opacity 0) vm.opacity 1},16) *//script /body /html 二、生命周期_挂载流程 !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlescript src./js/vue.js/script/head body!-- 准备好一个容器 --div idrooth2 v-iffalse你好啊/h2h2 :style{opacity}欢迎学习 Vue/h2h2当前的n值是{{n}}/h2button clickadd点我 n1/button/divscript typetext/javascriptconst vm new Vue({el: #root,// template: // div// h2当前的n值是{{n}}/h2// button clickadd点我 n1/button// /div// ,data: {opacity:1,n: 1},methods: {add(){this.n}},beforeCreate() {console.log(beforeCreate)// console.log(this);// debugger},created() {console.log(created)// console.log(this);// debugger},beforeMount() {console.log(beforeMount)// console.log(this);// debugger },mounted(){console.log(mounted)// console.log(this);// debugger /* setInterval(() {this.opacity - 0.01if (this.opacity 0) {this.opacity 1}}, 16) */}}) /script /body /html 三、生命周期_更新流程 在哪个生命周期 钩子中页面与数据尚未不同步 beforeUpdate !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlescript src./js/vue.js/script/head body!-- 准备好一个容器 --div idrooth2 v-iffalse你好啊/h2h2 :style{opacity}欢迎学习 Vue/h2h2当前的n值是{{n}}/h2button clickadd点我 n1/button/divscript typetext/javascriptconst vm new Vue({el: #root,// template: // div// h2当前的n值是{{n}}/h2// button clickadd点我 n1/button// /div// ,data: {opacity:1,n: 1},methods: {add(){this.n}},beforeCreate() {console.log(beforeCreate)// console.log(this);// debugger},created() {console.log(created)// console.log(this);// debugger},beforeMount() {console.log(beforeMount)// console.log(this);// debugger },mounted(){console.log(mounted,this.$el,this.$el instanceof HTMLElement)// console.log(this);// debugger /* setInterval(() {this.opacity - 0.01if (this.opacity 0) {this.opacity 1}}, 16) */},beforeUpdate() {console.log(beforeUpdate)// console.log(this.n); //点击按钮 此时已变成 2// debugger},updated() {console.log(updated)debugger},}) /script /body /html 四、生命周期_销毁流程 !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlescript src./js/vue.js/script/head body!-- 准备好一个容器 --div idrooth2 v-iffalse你好啊/h2h2 :style{opacity}欢迎学习 Vue/h2h2当前的n值是{{n}}/h2button clickadd点我 n1/buttonbutton clickbye点我销毁vm/button/divscript typetext/javascriptconst vm new Vue({el: #root,// template: // div// h2当前的n值是{{n}}/h2// button clickadd点我 n1/button// /div// ,data: {opacity:1,n: 1},methods: {add(){console.log(add);this.n},bye(){console.log(bye);this.$destroy()}},beforeCreate() {console.log(beforeCreate)// console.log(this);// debugger},created() {console.log(created)// console.log(this);// debugger},beforeMount() {console.log(beforeMount)// console.log(this);// debugger },mounted(){console.log(mounted,this.$el,this.$el instanceof HTMLElement)// console.log(this);// debugger /* setInterval(() {this.opacity - 0.01if (this.opacity 0) {this.opacity 1}}, 16) */},beforeUpdate() {console.log(beforeUpdate)// console.log(this.n); //点击按钮 此时已变成 2// debugger},updated() {console.log(updated)// debugger},beforeDestroy() {console.log(beforeDestroy)console.log(this.n)this.add() //仍可使用 add但对数据触发的操作不再更新所以页面中 的n不会改变},destroyed() {console.log(destroyed)},}) /script /body /html五、生命周期_总结 上面一共讲了8 个生命周期也就是4 对生命周期 beforeCreate 与 created  指数据检测与数据代理创建之前和之后 beforeMount 与 Mounted   beforeUpdate 与 updated beforeDestroy 与 destroy  常用的生命周期钩子      1.mounted: 发送ajax请求、启动定时器、绑定自定义事件、订阅消息等【初始化操作】。      2.beforeDestroy: 清除定时器、解绑自定义事件、取消订阅消息等【收尾工作】。 关于销毁Vue实例      1.  销毁后借助Vue开发者工具看不到任何信息。      2.  销毁后自定义事件会失效但原生DOM事件依然有效。 3.  一般不会在beforeDestroy 操作数据因为即便操作数据也不会再触发更新流程了。 !DOCTYPE html html langen headmeta charsetUTF-8meta http-equivX-UA-Compatible contentIEedgemeta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlescript src./js/vue.js/script/head body!-- 准备好一个容器 --div idroot!-- 需求点击按钮停止变换 --h2 :style{opacity}欢迎学习 Vue/h2button clickopacity 1透明度设置为1/buttonbutton clickstop停止变换/button/divscript typetext/javascriptconst vm new Vue({el: #root,data: {opacity:1,},methods: {stop(){this.$destroy()}},mounted(){ this.timer setInterval(() {this.opacity - 0.01console.log(定时器);if (this.opacity 0) {this.opacity 1}}, 16)},beforeDestroy() {console.log();clearInterval(this.timer)}, }) /script /body /html
http://www.eeditor.cn/news/125375/

相关文章:

  • 九江县网站建设中国建筑装饰网图片
  • 哪个网站可以帮忙做简历包装设计网站设计平台
  • 网站导航排版布局韩城建设局网站
  • 网站建站 在线制作中国住房和城乡建设部网站官网
  • 如何让百度搜索到自己的网站网站建设可行性方案模板
  • 做信息网站怎么赚钱用户界面设计报告
  • 手机网站微信代码企业网站建设方案策划书
  • 免费网站安全郑州金水区做网站公司
  • 中国建设银行网站首软件开发和网站建设
  • 网站网站做任务佣金违法榆林做网站电话
  • 珠宝网站开发asp 网站 内容静态化
  • wordpress插件 网站明星个人网页制作教程
  • 企业网站写好如何发布如何做自己的广告网站
  • 手机网站开发怎么收费可以在线做c语言的网站
  • 黑龙江住房和城乡建设厅网站网站设计 字体
  • 门户网站建设课程设计如何建网络营销网站
  • 免费网站浏览器网页设计作业成品免费下载
  • 好网站推荐dedecms做手机网站
  • 杭州网站设计精选柚v米科技网站域名用公司注册信息查询
  • 长沙个人做网站找网站公司做网站用了织梦可以吗
  • 网站建设平台还有没有趋势手机怎么做网站教程
  • 沧州制作网站门户网站技术方案
  • 怎么做导航网站泊头网站建设
  • 怎么制作手机网站甘肃省铁路投资建设集团有限公司网站
  • 怎么编辑自己的网站怎么用自己主机做网站_
  • 阿里云服务器做网站需要备案百度账号注册平台
  • ppt模板下载免费版网站wordpress 主题没有样式表
  • 顶做抱枕网站德国网站域名后缀
  • 网站建设简讯godaddy托管 wordpress
  • 网站首页关键词react.js做的网站