Skip to content

Commit

Permalink
docs: add examples for JSON string for inline props (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangDrescher committed Feb 23, 2023
1 parent cefa239 commit 1399d82
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/content/3.guide/1.writing/3.mdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,36 @@ defineProps(['type'])
::
::

Multiple props can be separated with a space:

```md
::alert{type="warning" icon="exclamation-circle"}
Oops! An error occurred
::
```

If you want to pass arrays or objects as props to components you can pass them as JSON string and prefix the prop key with a colon to automatically decode the JSON string.
Note that in this case you should use single quotes for the value string so you can use double quotes to pass a valid JSON string:

::code-group

```md [array.md]
::dropdown{:items='["Nuxt", "Vue", "React"]'}
::
```

```md [number-array.md]
::dropdown{:items='[1,2,3.5]'}
::
```

```md [object.md]
::chart{:options='{"responsive": true, "scales": {"y": {"beginAtZero": true}}}'}
::
```
::


### YAML method

The YAML method uses the `---` identifier to declare one prop per line, that can be useful for readability.
Expand Down

0 comments on commit 1399d82

Please sign in to comment.