This repository was archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
docs(examples): add jsx example #6870
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5ec709f
Add `useLayout` composables change layouts
CoinPool-Coin 19e603f
Add useLayout document
CoinPool-Coin 89ca7d0
Resolution `Newline required at end of file but not found eol-last`
CoinPool-Coin 2858c85
Merge branch 'main' into main
HomWang c2a18fb
Merge branch 'nuxt:main' into main
HomWang fd40e04
Merge branch 'nuxt:main' into main
HomWang c59cd90
Add `tsx` and `template`, and change the content to `Welcome to nuxt3`
CoinPool-Coin 0bf58cd
Rollback pages.md
CoinPool-Coin a25ebf4
Merge branch 'nuxt:main' into main
HomWang 8a409a5
rm useLayout and Add examples/advanced/tsx example
CoinPool-Coin 75b6f60
Resolution error Newline required at end of file but not found β¦
CoinPool-Coin bef858b
Add // @ts-ignore
CoinPool-Coin 992bdcc
Add eslint-disable-next-line @typescript-eslint/no-unused-vars
CoinPool-Coin eca7d33
remove use-layout (not related to this pr)
pi0 07e5239
rename package name to `example-tsx`
pi0 0a67113
refactor: show few different usages of tsx to define a component render
pi0 0393a71
use nuxt/ui
pi0 691a446
rename to jsx (jsx / tsx)
pi0 badac5e
add example link to pages tsx usage
pi0 44c5bd3
trigger ci
pi0 f48bf5f
use auto imports
pi0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
template: Example | ||
--- | ||
|
||
# JSX / TSX | ||
|
||
This example shows how to use [jsx syntax](https://vuejs.org/guide/extras/render-function.html#jsx-tsx) with typescript in Nuxt pages and components. | ||
|
||
::ReadMore{link="https://vuejs.org/guide/extras/render-function.html#jsx-tsx"} | ||
:: | ||
|
||
::sandbox{repo="nuxt/framework" branch="main" dir="examples/advanced/jsx" file="nuxt.config.ts"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script lang="tsx" setup> | ||
import { defineComponent } from 'vue' | ||
|
||
// Component could be a simple function with JSX syntax | ||
const Welcome = () => <span>Welcome </span> | ||
|
||
// Or using defineComponent setup that returns render function with JSX syntax | ||
const Nuxt3 = defineComponent(() => { | ||
return () => <span>nuxt3</span> | ||
}) | ||
|
||
// We can combine components with JSX syntax too | ||
const InlineComponent = () => ( | ||
<div> | ||
<Welcome /> | ||
<span>to </span> | ||
<Nuxt3 /> | ||
</div> | ||
) | ||
</script> | ||
|
||
<template> | ||
<NuxtExampleLayout example="advanced/jsx"> | ||
<InlineComponent /> | ||
<!-- Defined in components/jsx-component.ts --> | ||
<MyComponent message="This is an external JSX component" /> | ||
</NuxtExampleLayout> | ||
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineComponent } from 'vue' | ||
|
||
export default defineComponent({ | ||
props: { | ||
message: String | ||
}, | ||
render: (props) => { | ||
return ( | ||
<div> | ||
{ props.message } | ||
</div> | ||
) | ||
} | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineNuxtConfig } from 'nuxt' | ||
|
||
export default defineNuxtConfig({ | ||
modules: [ | ||
'@nuxt/ui' | ||
] | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "example-jsx", | ||
"private": true, | ||
"scripts": { | ||
"build": "nuxi build", | ||
"dev": "nuxi dev", | ||
"start": "nuxi preview" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/ui": "^0.2.0", | ||
"nuxt": "npm:nuxt3@latest" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.