[Vue] 強制渲染: $forceUpdate

Vue.js 技術揭秘 / async-component: 普通函數非同步裝置
https://ustbhuangyi.github.io/vue-analysis/components/async-component.html#%E6%99%AE%E9%80%9A%E5%87%BD%E6%95%B0%E5%BC%82%E6%AD%A5%E7%BB%84%E4%BB%B6

[Vue.js進階]從源碼角度剖析非同步裝置
https://juejin.im/post/5d6b66e1e51d456210163be5

因為 Vue 是資料驅動視圖重新渲染,但是當使用非同步(異步)組件時,會因為在非同步裝置載入過程中是沒有資料發生變化的,所以得通過其他辦法驅動渲染,例如執行 $forceUpdate 可以強制元件重新渲染一次。所以,Vue $forceUpdate 核心是調用渲染 watcher 的 update 方法,讓渲染 watcher 對應的回呼函數執行,也就是觸發了組件的重新渲染。


#Vue, forceUpdate, watcher, async-component, render, 強制, 渲染

留言