mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
docs(Popover): add select event demo
This commit is contained in:
parent
27ed9d1fb7
commit
1999195c46
@ -14,7 +14,7 @@ Vue.use(Popover);
|
|||||||
### Basic Usage
|
### Basic Usage
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-popover v-model="showPopover" :actions="actions">
|
<van-popover v-model="showPopover" :actions="actions" @select="onSelect">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="showPopover = true">
|
<van-button type="primary" @click="showPopover = true">
|
||||||
Light Theme
|
Light Theme
|
||||||
@ -24,6 +24,8 @@ Vue.use(Popover);
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
import { Toast } from 'vant';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -35,6 +37,11 @@ export default {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
onSelect(action) {
|
||||||
|
Toast(action.text);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Vue.use(Popover);
|
|||||||
当 Popover 弹出时,会基于 `reference` 插槽的内容进行定位。
|
当 Popover 弹出时,会基于 `reference` 插槽的内容进行定位。
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-popover v-model="showPopover" :actions="actions">
|
<van-popover v-model="showPopover" :actions="actions" @select="onSelect">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="showPopover = true">
|
<van-button type="primary" @click="showPopover = true">
|
||||||
浅色风格
|
浅色风格
|
||||||
@ -30,6 +30,8 @@ Vue.use(Popover);
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
import { Toast } from 'vant';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -38,6 +40,11 @@ export default {
|
|||||||
actions: [{ text: '选项一' }, { text: '选项二' }, { text: '选项三' }],
|
actions: [{ text: '选项一' }, { text: '选项二' }, { text: '选项三' }],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
onSelect(action) {
|
||||||
|
Toast(action.text);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
:actions="t('actions')"
|
:actions="t('actions')"
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
style="margin-left: 16px;"
|
style="margin-left: 16px;"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="show.lightTheme = true">
|
<van-button type="primary" @click="show.lightTheme = true">
|
||||||
@ -18,6 +19,7 @@
|
|||||||
theme="dark"
|
theme="dark"
|
||||||
:actions="t('actions')"
|
:actions="t('actions')"
|
||||||
style="margin-left: 16px;"
|
style="margin-left: 16px;"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="show.darkTheme = true">
|
<van-button type="primary" @click="show.darkTheme = true">
|
||||||
@ -48,6 +50,7 @@
|
|||||||
theme="dark"
|
theme="dark"
|
||||||
:actions="t('shortActions')"
|
:actions="t('shortActions')"
|
||||||
:placement="currentPlacement"
|
:placement="currentPlacement"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<div class="demo-popover-refer" />
|
<div class="demo-popover-refer" />
|
||||||
@ -64,6 +67,7 @@
|
|||||||
:actions="t('actionsWithIcon')"
|
:actions="t('actionsWithIcon')"
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
style="margin-left: 16px;"
|
style="margin-left: 16px;"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="show.showIcon = true">
|
<van-button type="primary" @click="show.showIcon = true">
|
||||||
@ -76,6 +80,7 @@
|
|||||||
v-model="show.disableAction"
|
v-model="show.disableAction"
|
||||||
:actions="t('actionsDisabled')"
|
:actions="t('actionsDisabled')"
|
||||||
style="margin-left: 16px;"
|
style="margin-left: 16px;"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<van-button type="primary" @click="show.disableAction = true">
|
<van-button type="primary" @click="show.disableAction = true">
|
||||||
@ -90,6 +95,7 @@
|
|||||||
v-model="show.customContent"
|
v-model="show.customContent"
|
||||||
placement="top-start"
|
placement="top-start"
|
||||||
style="margin-left: 16px;"
|
style="margin-left: 16px;"
|
||||||
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<van-grid
|
<van-grid
|
||||||
square
|
square
|
||||||
@ -117,6 +123,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Toast from '../../toast';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
i18n: {
|
i18n: {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
@ -207,6 +215,9 @@ export default {
|
|||||||
this.currentPlacement = value;
|
this.currentPlacement = value;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onSelect(action) {
|
||||||
|
Toast(action.text);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user