Caleb Porzio 4 tahun lalu
induk
melakukan
c540723be2
1 mengubah file dengan 16 tambahan dan 0 penghapusan
  1. 16 0
      packages/docs/src/en/globals/alpine-data.md

+ 16 - 0
packages/docs/src/en/globals/alpine-data.md

@@ -57,6 +57,22 @@ export default function () => ({
 })
 ```
 
+<a name="initial-parameters"></a>
+## Initial Parameters
+
+In addition to referencing `Alpine.data` providers by their name plainly (like `x-data="dropdown"`), you can also reference them as functions (`x-data="dropdown"`). By calling them as functions directly, you can pass in additional parameters to be used when creating the initial data object like so:
+
+```html
+<div x-data="dropdown(true)">
+```
+```js
+Alpine.data('dropdown', (initialOpenState = false) => ({
+    open: initialOpenState
+}))
+```
+
+Now, you can re-use the `dropdown` object, but provide it with different parameters as you need to.
+
 <a name="init-functions"></a>
 ## Init functions