Skip to content

Commit 930a0a0

Browse files
authored
Merge pull request #58 from mitjans/53-cant-capture-custom-events-using-v-directive
docs: cite vue documentation on using directives with custom components
2 parents 514c327 + fcd7bb0 commit 930a0a0

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

docs/content/3.features.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ Nuxt PostHog provides a [Vue directive](https://vuejs.org/guide/reusability/cust
5050
☝️ Whenever this button is clicked, an event will be sent to PostHog automatically
5151
::
5252

53+
::callout
54+
---
55+
icon: i-heroicons-exclamation-triangle
56+
color: amber
57+
---
58+
59+
You might find that the event is not being triggered when using the directive on a custom component. Citing [Vue official documentation](https://vuejs.org/guide/reusability/custom-directives#usage-on-components):
60+
61+
> Using custom directives on components is not recommended. Unexpected behaviour may occur when a component has multiple root nodes.
62+
::
63+
5364
This directive also accepts an object if you want to provide additional properties to this event:
5465

5566
```vue [app.vue]
@@ -65,6 +76,14 @@ This directive also accepts an object if you want to provide additional properti
6576
</template>
6677
```
6778

79+
::callout
80+
---
81+
icon: i-heroicons-sparkles
82+
---
83+
84+
This directive is typed and will provide suggestions while coding
85+
::
86+
6887
### Listen to custom events
6988

7089
You can listen to custom events (other than the default `click`) by passing in the event to the directive as an argument:
@@ -77,15 +96,6 @@ You can listen to custom events (other than the default `click`) by passing in t
7796
</template>
7897
```
7998

80-
::callout
81-
---
82-
83-
icon: i-heroicons-sparkles
84-
---
85-
86-
This directive is typed and will provide suggestions while coding
87-
::
88-
8999
### Auto-capture page views
90100

91101
By default, this module will capture page views automatically. If not desired, you can change this behavior:

0 commit comments

Comments
 (0)