Popover
Examples
Style variants
Available ui
prop values: s
/ m
.
<template>
<article>
<section>
<veui-select
v-model="ui"
class="select"
:options="options"
/>
<veui-button @click="reset">
reset
</veui-button>
</section>
<section>
<span ref="text">Move your mouse pointer over here.</span>
<veui-popover
:ui="ui"
target="text"
>
This is a popover.
</veui-popover>
</section>
</article>
</template>
<script>
import { Popover, Select, Button } from 'veui'
export default {
components: {
'veui-select': Select,
'veui-button': Button,
'veui-popover': Popover
},
data () {
return {
ui: null,
options: [
{
label: 's',
value: 's'
},
{
label: 'm',
value: 'm'
}
]
}
},
methods: {
reset () {
this.ui = null
}
}
}
</script>
<style lang="less" scoped>
section + section {
margin-top: 20px;
}
.select {
max-width: 120px;
margin-right: 10px;
}
</style>
Position
Use the position
prop to specify the position where the popover is displayed.
<template>
<article>
<section>
<veui-checkbox
v-model="aimCenter"
ui="s"
>
Aim center
</veui-checkbox>
</section>
<section class="grid">
<veui-popover
:open.sync="open"
:target="target"
:position="position"
:aim-center="aimCenter"
>
Hello.
</veui-popover>
<veui-button
ref="top-start"
style="grid-area: 1 / 2"
@mouseenter="show('top-start')"
>
top-start
</veui-button>
<veui-button
ref="top"
style="grid-area: 1 / 3"
@mouseenter="show('top')"
>
top
</veui-button>
<veui-button
ref="top-end"
style="grid-area: 1 / 4"
@mouseenter="show('top-end')"
>
top-end
</veui-button>
<veui-button
ref="right-start"
style="grid-area: 2 / 5"
@mouseenter="show('right-start')"
>
right-start
</veui-button>
<veui-button
ref="right"
style="grid-area: 3 / 5"
@mouseenter="show('right')"
>
right
</veui-button>
<veui-button
ref="right-end"
style="grid-area: 4 / 5"
@mouseenter="show('right-end')"
>
right-end
</veui-button>
<veui-button
ref="bottom-start"
style="grid-area: 5 / 2"
@mouseenter="show('bottom-start')"
>
bottom-start
</veui-button>
<veui-button
ref="bottom"
style="grid-area: 5 / 3"
@mouseenter="show('bottom')"
>
bottom
</veui-button>
<veui-button
ref="bottom-end"
style="grid-area: 5 / 4"
@mouseenter="show('bottom-end')"
>
bottom-end
</veui-button>
<veui-button
ref="left-start"
style="grid-area: 2 / 1"
@mouseenter="show('left-start')"
>
left-start
</veui-button>
<veui-button
ref="left"
style="grid-area: 3 / 1"
@mouseenter="show('left')"
>
left
</veui-button>
<veui-button
ref="left-end"
style="grid-area: 4 / 1"
@mouseenter="show('left-end')"
>
left-end
</veui-button>
</section>
</article>
</template>
<script>
import { Popover, Button, Checkbox } from 'veui'
export default {
components: {
'veui-popover': Popover,
'veui-button': Button,
'veui-checkbox': Checkbox
},
data () {
return {
target: null,
position: null,
open: false,
aimCenter: false
}
},
methods: {
show (position) {
this.target = this.$refs[position]
this.position = position
this.open = true
}
}
}
</script>
<style lang="less" scoped>
section + section {
margin-top: 20px;
}
.grid {
display: grid;
grid-template-columns: auto auto auto auto auto;
grid-gap: 12px;
justify-content: center;
align-items: center;
}
</style>
Trigger
Use the trigger
prop to specify when to show/hide the popover.
trigger="hover"
hover
over here.<template>
<article>
<section>
<code>trigger="{{ trigger }}"</code>
</section>
<section>
Open trigger: <veui-select
v-model="open"
:options="triggers"
/>
</section>
<section>
Close trigger: <veui-select
v-model="close"
:options="triggers"
/>
</section>
<section>
<span
ref="text"
tabindex="0"
>Trigger <b><code>{{ open }}</code></b> over here.</span>
<veui-popover
target="text"
:trigger="trigger"
>
This is a popover.
</veui-popover>
</section>
</article>
</template>
<script>
import { Popover, Select } from 'veui'
export default {
components: {
'veui-popover': Popover,
'veui-select': Select
},
data () {
return {
open: 'hover',
close: 'hover',
triggers: [
{ label: 'hover', value: 'hover' },
{ label: 'click', value: 'click' },
{ label: 'mousedown', value: 'mousedown' },
{ label: 'mouseup', value: 'mouseup' },
{ label: 'focus', value: 'focus' }
]
}
},
computed: {
trigger () {
if (this.open === this.close) {
return this.open
}
return `${this.open}-${this.close}`
}
}
}
</script>
<style lang="less" scoped>
section + section {
margin-top: 20px;
}
span {
outline: none;
&.focus-visible {
outline: 2px solid #ccc;
outline-offset: 3px;
}
}
</style>
Title and operations
Use the title
prop or title
slot to specify the title of the popover.
Use the foot
prop to enable the bottom operation area. Use the ok-label
prop and cancel-label
prop to set the text of the buttons in the popover. Use the foot
slot to customize the bottom operation area.
<template>
<article>
<section>
<veui-button
ref="btn1"
class="button"
>
按钮1
</veui-button>
<veui-button
ref="btn2"
class="button"
>
按钮2
</veui-button>
<veui-popover
target="btn1"
title="Popover Title"
ok-label="好"
cancel-label="否"
foot
>
This is a popover.
</veui-popover>
<veui-popover
target="btn2"
title="Popover Title"
foot
>
This is a popover.
<template #foot>
Popover foot
</template>
</veui-popover>
</section>
</article>
</template>
<script>
import { Popover, Button } from 'veui'
export default {
components: {
'veui-button': Button,
'veui-popover': Popover
}
}
</script>
<style lang="less" scoped>
.button + .button {
margin-left: 200px;
}
</style>
API
Props
Name | Type | Default | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
ui | string | - | The preset style.
| ||||||
open | boolean | false |
Whether to show the popover. | ||||||
target | string | Vue | Node | - | Refer to the target prop of the Overlay component. | ||||||
position | string | 'top' | Specify the positioning parameters. Use the positioning syntax of Popper.js, and refer to | ||||||
trigger | string | 'hover' | The way to trigger the popover. The value specified by the For example, | ||||||
hide-delay | number | tooltip.hideDelays | The delay time in milliseconds after the closing condition is met. It can be used to prevent the cursor from entering the popover before it is automatically closed after moving out of the target . | ||||||
overlay-class | string | Array | Object | - | Refer to the overlay-class prop of the Overlay component. | ||||||
overlay-style | string | Array | Object | - | Refer to the overlay-style prop of the Overlay component. | ||||||
title | string | - | Used to customize the title content. | ||||||
foot | boolean | false | Used to enable the bottom operation area. | ||||||
ok-label | string | - | The text content of the "OK" button. | ||||||
cancel-label | string | - | The text content of the "Cancel" button. |
Slots
Name | Description |
---|---|
default | The content of the popover. |
title | Used to customize the title content. |
foot | Used to customize the bottom operation area. |
Events
Name | Description |
---|---|
ok | Triggered when the "OK" button is clicked. |
cancel | Triggered when the "Cancel" button is clicked. |