Comments (2)
- As soon as
temp.value >= 80
evaluates totrue
, the Javascript runtime will no longer evaluate the second condition (height.value >= 80
) - Consequently,
height.value
isn't being accessed anymore, - and consequently, it no longer is a reactive dependency of the effect.
This is indeed a small footgun in watchEffect()
due to how conditions are evaluated (or skipped) in JS.
another possible solution/workaround:
watchEffect(function () {
console.log(">>>>>>>>>>", i++)
// read all reactive depenencies outside of condition:
const t = temp.value
const h = height.value
if (t >= 60 || h >= 80) {
console.log("触发警告", temp.value)
}
I'll close this since it's not something we can solve in the implementation.
from core.
I see. Thank you for your time.thank you!
from core.
Related Issues (20)
- Teste Vue 3
- Component rerender does not behave as expected HOT 4
- hydrateOnVisible() throws an error if the component does not render an element HOT 1
- Vue 3.5.6 memory leaks HOT 19
- TransitionGroup hydration mismatch (caused by comment)
- Type Interference for Props is not working with wrapped setup methods
- [@vue/compiler-sfc] Failed to resolve index type into finite keys HOT 1
- useSlots().*() return Symbol(v-fgt) HOT 2
- Inconsistent behavior for stop() at a computed ref between 3.4.38 and 3.5.6 HOT 2
- Improve type hints that were worsened by adding a second type argument to the `Ref` type HOT 4
- When using Vue's runtime template, passing rootProps of type ref results in a props validation error. HOT 3
- 数据渲染问题 HOT 2
- scoped style 样式应用失败 HOT 4
- scoped style 在多节点情况下样式应用失败 HOT 2
- Dep leak for property keys
- triggerRef throw error: Cannot read properties of undefined (reading 'trigger')
- watch deep options incorrect action HOT 4
- 我们测试了下,发现 vue3 的 v-for 性能比 vue2 的差很多 HOT 2
- 在 computed 中设置值,有时候不会重新执行 HOT 2
- Reactivity in object is lost
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.