You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 1, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: content/1.vue/2.reactivity/index.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,35 +4,37 @@ ogImage: true
4
4
5
5
# Reactivity Part 1
6
6
7
-
Vue provides [a great reactivity system](https://vuejs.org/guide/essentials/reactivity-fundamentals.html) that tracks changes to the data and triggers updates automatically, allowing you to have your UI always up-to-date with the data. Vue's reactivity comes with a few primitives: `ref`, `reactive`, `computed` and `watch`.
-[`ref()`](https://vuejs.org/api/reactivity-core.html#ref) creates a container to hold a single value, that can be tracked automatically when the value changes. The value can be accessed or updated via `.value`property.
-[`computed()`](https://vuejs.org/api/reactivity-core.html#computed) takes a getter function and returns a `ref`object, that reflects the return value of the getter function.
Here in the playground, we've created a ref object named `count`to hold a number, and a computed object named `double`that calculates the double of `count`. Vue will smartly know that `double`depends on `count`, so whenever `count`changes,`double`will re-calculate automatically.
**Note**: Refs will be [auto unwrapped by Vue](https://vuejs.org/guide/essentials/reactivity-fundamentals.html#declaring-reactive-state-1) when referenced in the `<template>`, The `.value`is only needed when accessing the ref in `<script>`or JavaScript outside of Vue components.
0 commit comments