Skip to content

Commit

Permalink
docs: add once option on watcher* Update watchers.mdadd once option d…
Browse files Browse the repository at this point in the history
…escription on watcher* docs: column spacing (#940) (#941)

Co-authored-by: KumJungMin <[email protected]>
  • Loading branch information
edimitchel and KumJungMin authored Feb 20, 2024
1 parent c3121cd commit 096cc44
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/guide/components/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ Le `type` peut être l'un des constructeurs natifs suivants :
- `Date`
- `Function`
- `Symbol`
- `Error`

De plus, `type` peut également être une classe personnalisée ou une fonction constructeur et l'assertion sera faite avec une vérification `instanceof`. Par exemple, étant donné la classe suivante :

Expand Down
36 changes: 36 additions & 0 deletions src/guide/essentials/watchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,42 @@ watch(

</div>


## Observateurs unitaires <sup class="vt-badge" data-text="3.4+" /> {#once-watchers}

La fonction de rappel de l'observateur sera exécutée dès lors qu'une source observée change. Si vous voulez que la fonction de rappel soit déclenchée une seule fois quand il y a un changement, utilisez l'option `once: true`.

<div class="options-api">

```js
export default {
watch: {
source: {
handler(newValue, oldValue) {
// quand `source` change, déclenchée une seule fois
},
once: true
}
}
}
```

</div>

<div class="composition-api">

```js
watch(
source,
(newValue, oldValue) => {
// quand `source` change, déclenchée une seule fois
},
{ once: true }
)
```

</div>

<div class="composition-api">

## `watchEffect()` \*\* {#watcheffect}
Expand Down

0 comments on commit 096cc44

Please sign in to comment.