File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed
packages/core/useMutationObserver Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -8,26 +8,19 @@ Watch for changes being made to the DOM tree. [MutationObserver MDN](https://dev
8
8
9
9
## Usage
10
10
11
- ``` ts
11
+ ``` vue
12
+ <script setup lang="ts">
12
13
import { useMutationObserver } from '@vueuse/core'
13
14
import { ref, useTemplateRef } from 'vue'
14
15
15
- export default {
16
- setup() {
17
- const el = useTemplateRef (' el' )
18
- const messages = ref ([])
16
+ const el = useTemplateRef('el')
17
+ const messages = ref([])
19
18
20
- useMutationObserver (el , (mutations ) => {
21
- if (mutations [0 ])
22
- messages .value .push (mutations [0 ].attributeName )
23
- }, {
24
- attributes: true ,
25
- })
26
-
27
- return {
28
- el ,
29
- messages ,
30
- }
31
- },
32
- }
19
+ useMutationObserver(el, (mutations) => {
20
+ if (mutations[0])
21
+ messages.value.push(mutations[0].attributeName)
22
+ }, {
23
+ attributes: true,
24
+ })
25
+ </script>
33
26
```
You can’t perform that action at this time.
0 commit comments