How should I create a plugin that adds a function named struct
(like a created()
hook) to all components?
Also, I want my plugin to have access to the structure
return value.
export default { structure() { // Access to context } }
I have to mention that I use Inertia JS.
You can use VueMixinsorCombinables.
Both can provide you with some shared functions and variables. But I don't know how to define new hooks in Vue like create() . I have to start your function in created() myself. Of course, you can use mixins to override existing Vue hooks.
Mixin is very convenient, butis no longer recommended
There is no
created()
in the Composition API, so you must useonBeforeMount()
oronMounted()
This is a very basic example using both techniques