Skip to content

Commit

Permalink
docs(useToggle): note about events in template (#2279)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
avegancafe and antfu committed Oct 16, 2022
1 parent 66f56d2 commit fd4e699
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/shared/useToggle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ import { useDark, useToggle } from '@vueuse/core'
const isDark = useDark()
const toggleDark = useToggle(isDark)
```

Note: be aware that the toggle function accepts the first argument as the override value. You might want to avoid directly passing the function to events in the template, as the event object will pass in.

```html
<!-- caution: $event will be pass in -->
<button @click="toggleDark" />
<!-- recommended to do this -->
<button @click="toggleDark()" />
```

0 comments on commit fd4e699

Please sign in to comment.