javascript - 在vue項目中遇到的問題:DOMException
問題描述
用vue做項目的時候,拋出異常:DOMException: Failed to execute ’insertBefore’ on ’Node’: The node before which the new node is to be inserted is not a child of this node.

描述:這個問題之前在網(wǎng)上搜索過,從很多參考資料中看出,和v-if和v-show有關(guān)系,但是并沒有給出過詳細(xì)合理的解釋以及解決方案,在此提出問題,希望遇到過解決的道友給出解釋。
問題解答
回答1:經(jīng)過查找資料:https://github.com/vuejs/vue-... https://github.com/vuejs/vue/...以上鏈接可參照。
本人推測當(dāng)頁面Dom在還沒有渲染完成的情況下,http請求回來的數(shù)據(jù)被插入到未知節(jié)點中,導(dǎo)致出現(xiàn)這種錯誤。
情景:點擊按鈕從服務(wù)器請求數(shù)據(jù),更新vnode,更新渲染結(jié)果。解決: 對需要渲染的模板外層添加<p v-if='isShow'><p v-for=''></p></p>,點擊按鈕開始請求數(shù)據(jù)的時候@click='isShow=false', 當(dāng)成功請求數(shù)據(jù)時,在回調(diào)函數(shù)中cb(isShow=ture). 保證 更新數(shù)據(jù)的時候先移除后插入*
相關(guān)文章:
1. javascript - 在移動端input type="number" 鍵盤沒法彈起2. java - 關(guān)于aop在controller不起用的問題3. java - com.android.internal.R.attr.dialogTheme 這個dialogTheme的內(nèi)容再哪里查看?4. mysql 怎么做到update只更新一行數(shù)據(jù)?5. android glide asbitmap 在baseadpter中的問題6. java如何高效讀寫10G以上大文件7. javascript - immutable配合react提升性能?8. php對mysql提取數(shù)據(jù)那種速度更快9. javascript - ionic1的插件如何遷移到ionic2的項目中10. python小白 自學(xué)看書遇到看不懂的地方

網(wǎng)公網(wǎng)安備