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

View File

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