docs: prefer using ref (#9285)

* docs: prefer using ref

* docs: fix lint error
This commit is contained in:
neverland
2021-08-18 16:39:09 +08:00
committed by GitHub
parent 5adaeb704d
commit c3ad21791b
23 changed files with 577 additions and 621 deletions

View File

@@ -22,21 +22,19 @@ app.use(TreeSelect);
```html
<van-tree-select
v-model:active-id="state.activeId"
v-model:main-active-index="state.activeIndex"
v-model:active-id="activeId"
v-model:main-active-index="activeIndex"
:items="items"
/>
```
```js
import { reactive } from 'vue';
import { ref } from 'vue';
export default {
setup() {
const state = reactive({
activeId: 1,
activeIndex: 0,
});
const activeId = ref(1);
const activeIndex = ref(0);
const items = [
{
text: 'Group 1',
@@ -55,8 +53,9 @@ export default {
];
return {
state,
items,
activeId,
activeIndex,
};
},
};
@@ -66,21 +65,19 @@ export default {
```html
<van-tree-select
v-model:active-id="state.activeIds"
v-model:main-active-index="state.activeIndex"
v-model:active-id="activeIds"
v-model:main-active-index="activeIndex"
:items="items"
/>
```
```js
import { reactive } from 'vue';
import { ref } from 'vue';
export default {
setup() {
const state = reactive({
activeId: [1, 2],
activeIndex: 0,
});
const activeId = ref([1, 2]);
const activeIndex = ref(0);
const items = [
{
text: 'Group 1',
@@ -99,8 +96,9 @@ export default {
];
return {
state,
items,
activeId,
activeIndex,
};
},
};

View File

@@ -24,21 +24,19 @@ app.use(TreeSelect);
```html
<van-tree-select
v-model:active-id="state.activeId"
v-model:main-active-index="state.activeIndex"
v-model:active-id="activeId"
v-model:main-active-index="activeIndex"
:items="items"
/>
```
```js
import { reactive } from 'vue';
import { ref } from 'vue';
export default {
setup() {
const state = reactive({
activeId: 1,
activeIndex: 0,
});
const activeId = ref(1);
const activeIndex = ref(0);
const items = [
{
text: '浙江',
@@ -57,8 +55,9 @@ export default {
];
return {
state,
items,
activeId,
activeIndex,
};
},
};
@@ -70,21 +69,19 @@ export default {
```html
<van-tree-select
v-model:active-id="state.activeIds"
v-model:main-active-index="state.activeIndex"
v-model:active-id="activeIds"
v-model:main-active-index="activeIndex"
:items="items"
/>
```
```js
import { reactive } from 'vue';
import { ref } from 'vue';
export default {
setup() {
const state = reactive({
activeId: [1, 2],
activeIndex: 0,
});
const activeId = ref([1, 2]);
const activeIndex = ref(0);
const items = [
{
text: '浙江',
@@ -103,8 +100,9 @@ export default {
];
return {
state,
items,
activeId,
activeIndex,
};
},
};