How can we pass parameters to Alpine.data in Alpine.js v3? #1642
Replies: 1 comment 1 reply
-
|
At the moment you can't but there is PR to support this #1580. I'd recommend for now refactoring to something like
Or just don't use Alpine.data. If you're building a bundle you're likely exporting library somewhere so I honestly just prefer something like |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I am now using the newest version of Alpine which is v3.
Making reusable components needs to be registered using the Alpine.data.
This is the alpinejs.js
This is what I have in the components/form.js
This is the html part:
<div x-data="form({test:'test'})"></div>This is the error I get in the console:

Any idea how to pass parameters to Alpine.data?
Beta Was this translation helpful? Give feedback.
All reactions