docs: update README for TypeScript

This commit is contained in:
Amour1688 2020-09-01 10:14:36 +08:00
parent dcf22537b1
commit 1b7fb1b307
2 changed files with 53 additions and 57 deletions

View File

@ -70,25 +70,10 @@ const App = {
``` ```
```jsx ```jsx
const App = defineComponent(() => { import { withModifiers, defineComponent } from 'vue';
const count = ref(0);
const inc = () => { const App = defineComponent({
count.value++; setup() {
};
return () => (
<div onClick={inc}>
{count.value}
</div>
);
});
```
```jsx
import { withModifiers } from 'vue';
const App = () => {
const count = ref(0); const count = ref(0);
const inc = () => { const inc = () => {
@ -100,7 +85,8 @@ const App = () => {
{count.value} {count.value}
</div> </div>
); );
} }
});
``` ```
Fragment Fragment
@ -204,6 +190,18 @@ const App = {
}; };
``` ```
### 在 TypesSript 中使用
`tsconfig.json`:
```json
{
"compilerOptions": {
"jsx": "preserve"
}
}
```
## 谁在用 ## 谁在用
<table> <table>

View File

@ -56,7 +56,7 @@ configuring custom elements
functional component functional component
```jsx ```jsx
const App = () => <div></div>; const App = () => <div>Vue 3.0</div>;
``` ```
with render with render
@ -70,25 +70,10 @@ const App = {
``` ```
```jsx ```jsx
const App = defineComponent(() => { import { withModifiers, defineComponent } from 'vue';
const count = ref(0);
const inc = () => { const App = defineComponent({
count.value++; setup() {
};
return () => (
<div onClick={inc}>
{count.value}
</div>
);
});
```
```jsx
import { withModifiers } from 'vue';
const App = () => {
const count = ref(0); const count = ref(0);
const inc = () => { const inc = () => {
@ -100,7 +85,8 @@ const App = () => {
{count.value} {count.value}
</div> </div>
); );
} }
})
``` ```
Fragment Fragment
@ -204,6 +190,18 @@ const App = {
}; };
``` ```
### In TypesSript
`tsconfig.json`:
```json
{
"compilerOptions": {
"jsx": "preserve"
}
}
```
## Who is using ## Who is using
<table> <table>