Comments (3)
@LinusBorg okay, but why does
@click="btnClick(n)"
causes all refs to set again, but@click="btnClick(1)"
doesn't? In both cases there are state changes
This is a performance optimization. When using @click="btnClick(1)"
, the button
vnode is static because it doesn't use any other state. Vue skips these static nodes during the patch
update, only updating dynamicChildren
(source).
Ref updates occur within the patch
logic (source), so this won't cause the ref to be set again.
Hope this helps :)
from core.
That's expected behaviour. Any state. change will update the whole template, and in that process, all refs are set again.
You can use v-memo to optimize update behaviour in v-for loops.
And you can use lifecycle hooks to reset the array in beforeUpdate
from core.
@LinusBorg okay, but why does @click="btnClick(n)"
causes all refs to set again, but @click="btnClick(1)"
doesn't? In both cases there are state changes
from core.
Related Issues (20)
- Maximum recursive updates exceeded in component in 3.4.27 HOT 9
- Unresolvable type reference or unsupported built-in utility type 以及热更新失败 HOT 1
- defineModel is triggering update event, even if its value didn't actually change HOT 4
- Failed to add a reactive to the instance object HOT 5
- Invalid prop: type check failed, Expected Object when using keyof on type intersection
- 属性穿透失败 HOT 7
- A value is not reactive when it is created by `toRef` with an plain object. HOT 3
- defineAsyncComponent意外报错 HOT 3
- significant increase in size of `@vue/server-renderer`
- defineModel push array doesnt trigger the value HOT 5
- KeepAlive: `activated`/`deactivated` hooks not always run for descendants HOT 2
- Regarding the use of ref HOT 2
- A breakpoint ("debugger") inside a computed causes to "Maximum call stack size exceeded" error HOT 1
- bug(vue-model): does not pass values when using an object string HOT 1
- Compiled Vue 2.7 Script Setup Components crash when mounted in Vue 3 Compat HOT 2
- vue setup组件的引用的实例类型会提示props相关的类型, 但是实际运行是没有的 HOT 2
- `<script setup generic>` throws TypeScript error when using prop defaults HOT 2
- `onUnmounted` doesn't run if slot content is wrapped in a div (within this tab structure)
- chain computed lost reactivity when computed effect happens HOT 2
- Attribute stringification HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.