naive-ui/demo/documentation/components/popover/enUS/manual-position.demo.md

30 lines
569 B
Markdown
Raw Normal View History

2019-12-03 18:36:21 +08:00
# Manually Positioned
Click it.
2019-12-03 18:36:21 +08:00
```html
<div style="width: 200px; height: 200px; background-color: rgba(0, 128, 0, .5);" @click="handleClick"></div>
2020-09-10 14:18:02 +08:00
<n-popover :show="showPopover" :x="x" :y="y" manually-positioned>
2020-01-30 17:38:14 +08:00
Cool!
2019-12-03 18:36:21 +08:00
</n-popover>
```
```js
export default {
methods: {
handleClick(e) {
2020-01-22 16:29:34 +08:00
if (this.showPopover) {
this.showPopover = false
} else {
2019-12-03 18:36:21 +08:00
this.showPopover = true
this.x = e.clientX
this.y = e.clientY
2020-01-22 16:29:34 +08:00
}
2019-12-03 18:36:21 +08:00
}
},
data () {
return {
showPopover: false,
x: 0,
y: 0
}
}
}
```