鍍金池/ 問(wèn)答/HTML/ 為什么React異步請(qǐng)求數(shù)據(jù)報(bào)錯(cuò)而Vue不會(huì)出現(xiàn)類(lèi)似報(bào)錯(cuò)

為什么React異步請(qǐng)求數(shù)據(jù)報(bào)錯(cuò)而Vue不會(huì)出現(xiàn)類(lèi)似報(bào)錯(cuò)

用react在componentDidMount下ajax 偶爾會(huì)出現(xiàn)這種錯(cuò)誤

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the Timer component.

大概是從DOM中移除了react組件,這時(shí)才調(diào)用setState改變組件的狀態(tài)
但是印象里vue好像不會(huì)出現(xiàn)類(lèi)似的報(bào)錯(cuò)
是因?yàn)殇秩緳C(jī)制的不同嗎?
請(qǐng)大神們賜教 謝謝

回答
編輯回答
愚念

提示明明寫(xiě)著:你的setState用錯(cuò)地方了。

2017年5月21日 11:06
編輯回答
墻頭草

這是警告,不是錯(cuò)誤,你不管他也沒(méi)什么太大關(guān)系
如果有強(qiáng)迫癥的話可以加入下面的代碼解決

componentWillUnmount(){
    this.setState=()=>{};
}
2018年4月13日 12:11