-
|
One can do this: x-data="{
init() { ... }
}"And this: x-data="{
foo() { ... }
}"
x-init="foo()"Is there a difference between |
Beta Was this translation helpful? Give feedback.
Answered by
ekwoka
Oct 21, 2025
Replies: 1 comment 4 replies
-
|
Order of execution: |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One is bound in the Dom the other in the component.
X-init can go on any element even if it's not a component root element.
In the most strict sense, init() is useful for setup work a component will always need to do, while x-init is good when it's this specific instance needs to do something.