https://github.com/zhangyuang/vue3-staticnodecache-error
https://github.com/zhangyuang/vue3-staticnodecache-error
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zhangyuang/vue3-staticnodecache-error
- Owner: zhangyuang
- Created: 2022-03-30T08:14:16.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-30T08:31:29.000Z (over 3 years ago)
- Last Synced: 2025-07-14T18:00:10.559Z (5 months ago)
- Language: Vue
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```bash
$ yarn && yarn dev
```
root component will remove element in beforeUnmount will generate side effect
click `tohello` to open hello component and return back to root component, `foo` element will never be rerender because root component is static and be cached
```ts
will never be rerender after unmount when children list too large
- 列表1
- 列表2
- 列表3
- 列表4
- 列表5
- 列表6
- 列表7
- 列表8
- 列表9
- 列表10
- 列表11
- 列表12
- 列表13
- 列表14
- 列表15
- 列表16
toHello
import { onBeforeUnmount, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const foo = () => {
router.push('/hello')
}
onMounted(() => {
console.log('mounted')
})
onBeforeUnmount(() => {
const box = document.querySelector('.foo')
box?.remove()
})
```