docs: add v-models docs (#207)

This commit is contained in:
John60676 2020-12-08 14:21:22 +08:00 committed by GitHub
parent 1d34d13cfd
commit 215aaedd05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 8 deletions

View File

@ -161,11 +161,49 @@ v-model
```js
h(A, {
'argument': val,
"argumentModifiers": {
"modifier": true
argument: val,
argumentModifiers: {
modifier: true
},
"onUpdate:argument": $event => val = $event
'onUpdate:argument': $event => val = $event
})
```
v-models
> 注意: 你应该传递一个二维数组给 v-models。
```jsx
<A v-models={[[foo], [bar, 'bar']]} />
```
```jsx
<A v-models={[[foo, 'foo'], [bar, 'bar']]} />
```
```jsx
<A
v-models={[
[foo, ['modifier']],
[bar, 'bar', ['modifier']],
]}
/>
```
会变编译成:
```js
h(A, {
modelValue: foo,
modelModifiers: {
modifier: true,
},
'onUpdate:modelValue': $event => foo = $event,
bar: bar,
barModifiers: {
modifier: true,
},
'onUpdate:bar': $event => bar = $event,
})
```

View File

@ -161,11 +161,49 @@ Will compile to:
```js
h(A, {
'argument': val,
"argumentModifiers": {
"modifier": true
argument: val,
argumentModifiers: {
modifier: true
},
"onUpdate:argument": $event => val = $event
'onUpdate:argument': $event => val = $event
})
```
v-models
> Note: You should pass a Two-dimensional Arrays to v-models.
```jsx
<A v-models={[[foo], [bar, 'bar']]} />
```
```jsx
<A v-models={[[foo, 'foo'], [bar, 'bar']]} />
```
```jsx
<A
v-models={[
[foo, ['modifier']],
[bar, 'bar', ['modifier']],
]}
/>
```
Will compile to:
```js
h(A, {
modelValue: foo,
modelModifiers: {
modifier: true,
},
'onUpdate:modelValue': $event => foo = $event,
bar: bar,
barModifiers: {
modifier: true,
},
'onUpdate:bar': $event => bar = $event,
})
```