對(duì)生命周期鉤子函數(shù)的理解_第1頁(yè)
對(duì)生命周期鉤子函數(shù)的理解_第2頁(yè)
對(duì)生命周期鉤子函數(shù)的理解_第3頁(yè)
對(duì)生命周期鉤子函數(shù)的理解_第4頁(yè)
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、=3對(duì)生命周期鉤子函數(shù)的理解對(duì)生命周期鉤子函數(shù)的理解,其實(shí)這也是我看得別人的然后自己修改了一下,下面是我做的實(shí)驗(yàn),messagevinputtype=buttonclick=changevalue=E新數(shù)據(jù)/vinputtype=buttonclick=destroyvalue/肖毀數(shù)據(jù)/vscripttype=text/javascriptvarvm=newVue(el:#app,data:message:WelcomeVue,methods:change()this.message=Daturaisme;,destroy()vm.$destroy();,beforeCreate:funct

2、ion()console.group(beforeCreate創(chuàng)建前狀態(tài)=);console.log(%c%s,color:red,el:+this.$el);/undefinedconsole.log(%c%s,color:red,data:+this.$data);/undefinedconsole.log(%c%s,color:red,message:+this.message);/undefined,created:function()console.group(created創(chuàng)建完畢狀態(tài)=);console.log(%c%s,color:red,el:+this.$el);/unde

3、finedconsole.log(%c%s,color:green,data:+this.$data);/objectObject=已被初始化console.log(%c%s,color:green,message:+this.message);/WelcomeVue=已被初始化,beforeMount:function()console.group(beforeMount掛載前狀態(tài)=);console.log(%c%s,color:green,el:+(this.$el);/已被初始化console.log(this.$el);/當(dāng)前掛在的元素console.log(%c%s,color:g

4、reen,data:+this.$data);/已被初始化console.log(%c%s,color:green,message:+this.message);/已被初始化,mounted:function()console.group(mounted掛載結(jié)束狀態(tài)=);console.log(%c%s,color:green,el:+this.$el);/已被初始化console.log(this.$el);console.log(%c%s,color:green,data:+this.$data);/已被初始化console.log(%c%s,color:green,message:+th

5、is.message);/已被初始化,beforeUpdate:function()alert(更新前狀態(tài)1);console.group(beforeUpdate更新前狀態(tài)=);/這里指的是頁(yè)面渲染新數(shù)據(jù)之前console.log(%c%s,color:green,el:+this.$el);console.log(this.$el);console.log(%c%s,color:green,data:+this.$data);console.log(%c%s,color:green,message:+this.message);alert(更新前狀態(tài)2);,updated:function

6、()console.group(updated更新完成狀態(tài)=);console.log(%c%s,color:green,el:+this.$el);console.log(this.$el);console.log(%c%s,color:green,data:+this.$data);console.log(%c%s,color:green,message:+this.message);,beforeDestroy:function()console.group(beforeDestroy肖毀前狀態(tài)=);console.log(%c%s,color:red,el:+this.$el);con

7、sole.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肖毀完成狀態(tài)=);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:re

8、d,message:+this.message)=3)看瀏覽器:頁(yè)面是這樣的:Exfl1、先看控制臺(tái)亡藺“飛CorsoIeS:lpcsNetworkPerfxmanze亡rrory也ppi正亦=3=3Qt:zpFilterD羽Itevels=3thsVueextensionforabetterdselopnenteKperisncenttM:Ei二hub,匚on八醫(yī)帖八Yaurunning7jemcfevel-ipnentrroderlakeiuretdturncrprixuctionhoHewhndepLqjin?forproduction.semretipsanttds:*2已is;orm

9、f:!/;亡pLjyjiFnt!:“Tse-forsCreatEWMMtS=el:ojrdefineddsta:urdefinednesscge:undefinedcreated暮舉擾態(tài):si:undefineddteta:objectObjectine55ap:UelconeVueTe-forscunt掛載前狀在=3el:cbjieztHTMLDivElEmenTUjirressaee:-rresiaEe;/pinputtyp=bu-lonzlict=chagevalue=更新數(shù)梔:di護(hù)daze:cbjeztObjectnesscge:helcoiEVuenounted隹驕?zhǔn)鵂钤?:obj

10、ect-nTMLDivEleKnt;tpXhelcoffiVue我們能發(fā)現(xiàn)掛載前el還是n去。,這里就是應(yīng)用的VirtualDOM(虛擬Dom)技術(shù),先把坑占住了。Lnpit二應(yīng)=Mt。沁u日銷富數(shù)據(jù)燈dis到后面mounted掛載的時(shí)候再把值渲染進(jìn)=3lata:objectObject2、點(diǎn)擊按鈕更新數(shù)據(jù)”上皿已皿=3=31)更新前狀態(tài)moiriTsd聲黠束匾=el:;csjeztHTMOivELsmenTcdivid=a,app,BWeLeoneLedaze:jjeztObject;message:ftElconeVuebeforeUpdate更術(shù)瞬:jject-nriDij:len?nt;ggt質(zhì):I1h-ioj+1VelcnmeVje=3=3頁(yè)面是這樣的:=32)更新后Tbe+crUpdate更逍前唸頁(yè)面是這樣的:H1V=etanessage:Dat12be!robiectHTLDiEJenentlTdivid叩A(chǔ)_dta:objectGtject;rKSUge:Occursisnt*dc&trcyedj韻

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論