最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

vue.js - What is 'effect' on Vue computed properties - Stack Overflow

matteradmin7PV0评论

If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value property, there's also .effect. I wasn't able to find any information about it, except that it's deprecated in Vue 3. Does anybody know why it was needed and what its use was? Why has it become deprecated? I'd also appreciate, if somebody shares a link to the page where this property would be documented.

If I inspect a computed property in Vue 2.7, I can see that, besides the well-known .value property, there's also .effect. I wasn't able to find any information about it, except that it's deprecated in Vue 3. Does anybody know why it was needed and what its use was? Why has it become deprecated? I'd also appreciate, if somebody shares a link to the page where this property would be documented.

Share Improve this question asked Nov 18, 2024 at 14:01 LazouskiLazouski 8110 bronze badges 1
  • Looks like it's an old API that was considered when migrating towards the v3. Was probably deprecated in favor of watchEffect. – kissu Commented Nov 18, 2024 at 14:46
Add a comment  | 

1 Answer 1

Reset to default 1

It's an undocumented API for internal purposes that contains a watcher that updates the computed value:

some libs rely on the presence effect for checking computed refs from normal refs, but the implementation doesn't matter

This seems plausible, because in Vue 3 computed and other special kinds of refs have internal properties that make them different from regular refs, but they don't exist in Vue 2 reactivity API.

In Vue itself, it's used for testing.

Post a comment

comment list (0)

  1. No comments so far