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,39 +70,25 @@ const App = {
``` ```
```jsx ```jsx
const App = defineComponent(() => { import { withModifiers, defineComponent } from 'vue';
const count = ref(0);
const inc = () => { const App = defineComponent({
count.value++; setup() {
}; const count = ref(0);
return () => ( const inc = () => {
<div onClick={inc}> count.value++;
{count.value} };
</div>
); return () => (
<div onClick={withModifiers(inc, ['self'])}>
{count.value}
</div>
);
}
}); });
``` ```
```jsx
import { withModifiers } from 'vue';
const App = () => {
const count = ref(0);
const inc = () => {
count.value++;
};
return () => (
<div onClick={withModifiers(inc, ['self'])}>
{count.value}
</div>
);
}
```
Fragment Fragment
```jsx ```jsx
@ -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,37 +70,23 @@ const App = {
``` ```
```jsx ```jsx
const App = defineComponent(() => { import { withModifiers, defineComponent } from 'vue';
const count = ref(0);
const inc = () => { const App = defineComponent({
count.value++; setup() {
}; const count = ref(0);
return () => ( const inc = () => {
<div onClick={inc}> count.value++;
{count.value} };
</div>
);
});
```
```jsx return () => (
import { withModifiers } from 'vue'; <div onClick={withModifiers(inc, ['self'])}>
{count.value}
const App = () => { </div>
const count = ref(0); );
}
const inc = () => { })
count.value++;
};
return () => (
<div onClick={withModifiers(inc, ['self'])}>
{count.value}
</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>