mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +08:00
docs(DropdownMenu): fix demo state (#9278)
This commit is contained in:
parent
cb25a8c4ae
commit
5adaeb704d
@ -23,20 +23,18 @@ app.use(DropdownItem);
|
||||
|
||||
```html
|
||||
<van-dropdown-menu>
|
||||
<van-dropdown-item v-model="state.value1" :options="option1" />
|
||||
<van-dropdown-item v-model="state.value2" :options="option2" />
|
||||
<van-dropdown-item v-model="value1" :options="option1" />
|
||||
<van-dropdown-item v-model="value2" :options="option2" />
|
||||
</van-dropdown-menu>
|
||||
```
|
||||
|
||||
```js
|
||||
import { reactive } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
value1: 0,
|
||||
value2: 'a',
|
||||
});
|
||||
const value1 = ref(0);
|
||||
const value2 = ref('a');
|
||||
const option1 = [
|
||||
{ text: 'Option1', value: 0 },
|
||||
{ text: 'Option2', value: 1 },
|
||||
@ -49,7 +47,8 @@ export default {
|
||||
];
|
||||
|
||||
return {
|
||||
state,
|
||||
value1,
|
||||
value2,
|
||||
option1,
|
||||
option2,
|
||||
};
|
||||
@ -61,16 +60,16 @@ export default {
|
||||
|
||||
```html
|
||||
<van-dropdown-menu>
|
||||
<van-dropdown-item v-model="state.value" :options="option" />
|
||||
<van-dropdown-item v-model="value" :options="option" />
|
||||
<van-dropdown-item title="Title" ref="item">
|
||||
<van-cell center title="Title">
|
||||
<template #right-icon>
|
||||
<van-switch v-model="state.switch1" size="24" active-color="#ee0a24" />
|
||||
<van-switch v-model="switch1" size="24" active-color="#ee0a24" />
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell center title="Title">
|
||||
<template #right-icon>
|
||||
<van-switch v-model="state.switch2" size="24" active-color="#ee0a24" />
|
||||
<van-switch v-model="switch2" size="24" active-color="#ee0a24" />
|
||||
</template>
|
||||
</van-cell>
|
||||
<div style="padding: 5px 16px;">
|
||||
@ -83,16 +82,14 @@ export default {
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const item = ref(null);
|
||||
const state = reactive({
|
||||
value: 0,
|
||||
switch1: false,
|
||||
switch2: false,
|
||||
});
|
||||
const value = ref(0);
|
||||
const switch1 = ref(false);
|
||||
const switch2 = ref(false);
|
||||
const options = [
|
||||
{ text: 'Option1', value: 0 },
|
||||
{ text: 'Option2', value: 1 },
|
||||
@ -104,7 +101,9 @@ export default {
|
||||
|
||||
return {
|
||||
item,
|
||||
state,
|
||||
value,
|
||||
switch1,
|
||||
switch2,
|
||||
options,
|
||||
onConfirm,
|
||||
};
|
||||
|
@ -23,8 +23,8 @@ app.use(DropdownItem);
|
||||
|
||||
```html
|
||||
<van-dropdown-menu>
|
||||
<van-dropdown-item v-model="state.value1" :options="option1" />
|
||||
<van-dropdown-item v-model="state.value2" :options="option2" />
|
||||
<van-dropdown-item v-model="value1" :options="option1" />
|
||||
<van-dropdown-item v-model="value2" :options="option2" />
|
||||
</van-dropdown-menu>
|
||||
```
|
||||
|
||||
@ -33,10 +33,8 @@ import { reactive } from 'vue';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
value1: 0,
|
||||
value2: 'a',
|
||||
});
|
||||
const value1 = ref(0);
|
||||
const value2 = ref('a');
|
||||
const option1 = [
|
||||
{ text: '全部商品', value: 0 },
|
||||
{ text: '新款商品', value: 1 },
|
||||
@ -49,7 +47,8 @@ export default {
|
||||
];
|
||||
|
||||
return {
|
||||
state,
|
||||
value1,
|
||||
value2,
|
||||
option1,
|
||||
option2,
|
||||
};
|
||||
@ -85,16 +84,14 @@ export default {
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const item = ref(null);
|
||||
const state = reactive({
|
||||
value: 0,
|
||||
switch1: false,
|
||||
switch2: false,
|
||||
});
|
||||
const value = ref(0);
|
||||
const switch1 = ref(false);
|
||||
const switch2 = ref(false);
|
||||
const options = [
|
||||
{ text: '全部商品', value: 0 },
|
||||
{ text: '新款商品', value: 1 },
|
||||
@ -106,7 +103,9 @@ export default {
|
||||
|
||||
return {
|
||||
item,
|
||||
state,
|
||||
value,
|
||||
switch1,
|
||||
switch2,
|
||||
options,
|
||||
onConfirm,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user