Demo:修复右键菜单中的二级菜单会超出边界的问题

This commit is contained in:
街角小林
2024-09-19 18:19:57 +08:00
parent 5d49d985c0
commit 9ebc416167

View File

@@ -344,12 +344,11 @@ export default {
// 计算右键菜单元素的显示位置
getShowPosition(x, y) {
this.subItemsShowLeft = false
const rect = this.$refs.contextmenuRef.getBoundingClientRect()
if (x + rect.width > window.innerWidth) {
x = x - rect.width - 20
this.subItemsShowLeft = true
}
this.subItemsShowLeft = x + rect.width + 150 > window.innerWidth
if (y + rect.height > window.innerHeight) {
y = window.innerHeight - rect.height - 10
}