<div id="app">
<p id="age">me:{{me()}}</p></div>new Vue({
el:"#app",
data:{
y:454,
},
methods:{
me(a){ console.log("methods is run",this.y) return this.y;
}
},
beforeUpdate(){ console.log("dom:",document.getElementById("age").innerHTML,this.y)
},
updated(){ console.log("dom:",document.getElementById("age").innerHTML,this.y)
}
}執(zhí)行順序是什么?
2 回答

揚(yáng)帆大魚
TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個(gè)贊
beforeupdate和updated可以看vue生命周期,me(a)方法調(diào)用了才會(huì)執(zhí)行

MYYA
TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊
目前這種情況下beforeUpdate,updated中的函數(shù)體應(yīng)該是不會(huì)執(zhí)行的,因?yàn)闆]有涉及到數(shù)據(jù)更新,然后me函數(shù)會(huì)被執(zhí)行
添加回答
舉報(bào)
0/150
提交
取消