Demo:修复右键菜单中的二级菜单会超出边界的问题
This commit is contained in:
parent
5d49d985c0
commit
9ebc416167
@ -344,12 +344,11 @@ export default {
|
|||||||
|
|
||||||
// 计算右键菜单元素的显示位置
|
// 计算右键菜单元素的显示位置
|
||||||
getShowPosition(x, y) {
|
getShowPosition(x, y) {
|
||||||
this.subItemsShowLeft = false
|
|
||||||
const rect = this.$refs.contextmenuRef.getBoundingClientRect()
|
const rect = this.$refs.contextmenuRef.getBoundingClientRect()
|
||||||
if (x + rect.width > window.innerWidth) {
|
if (x + rect.width > window.innerWidth) {
|
||||||
x = x - rect.width - 20
|
x = x - rect.width - 20
|
||||||
this.subItemsShowLeft = true
|
|
||||||
}
|
}
|
||||||
|
this.subItemsShowLeft = x + rect.width + 150 > window.innerWidth
|
||||||
if (y + rect.height > window.innerHeight) {
|
if (y + rect.height > window.innerHeight) {
|
||||||
y = window.innerHeight - rect.height - 10
|
y = window.innerHeight - rect.height - 10
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user