From cbb6bbe7f2c3cb262213c32ae3d824f33168c2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Tue, 10 Mar 2026 17:14:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BE=E6=8A=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/video/components/comment-info.vue | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/pages/plugins/video/components/comment-info.vue b/pages/plugins/video/components/comment-info.vue index 7d3236eb..48f707ab 100644 --- a/pages/plugins/video/components/comment-info.vue +++ b/pages/plugins/video/components/comment-info.vue @@ -6,11 +6,16 @@ {{ propComment.user.user_name_view }} - + - + + + + + + {{ item.label }} @@ -73,7 +78,9 @@ data() { return { // 下拉菜单选项数据 - dropdownOptions: [] + dropdownOptions: [], + // 下拉菜单位置信息 + dropdownMenuTop: 0 }; }, mounted() { @@ -83,14 +90,21 @@ // 使用computed属性映射props状态 drop_down_visible() { return this.propDropDownVisible; + }, + // 下拉菜单样式 + dropdownMenuStyle() { + return `top: ${this.dropdownMenuTop}px;` } }, methods: { isEmpty, init() { + const label1 = $t('common.delete'); + const label2 = $t('common.report'); + console.log(label1, label2); this.dropdownOptions = [ - { label: '删除', type: 'delete' }, - { label: '举报', type: 'report' } + { label: label1, type: 'delete' }, + { label: label2, type: 'report' } ] }, // 回复 @@ -118,11 +132,37 @@ }, // 切换下拉菜单 toggle_dropdown(e) { + // 获取 comment-option 的位置信息 + this.getDropdownPosition(); + // 通知父组件切换当前组件的下拉菜单状态 this.$emit('toggle_dropdown', this.propId); e.stopPropagation(); }, + + // 获取下拉菜单位置 + getDropdownPosition() { + try { + // #ifdef APP-NVUE + // nvue 环境使用 dom 模块 + const dom = weex.requireModule('dom'); + const commentOptionEl = document.getElementById(`comment-option-${this.propId}`); + if (commentOptionEl) { + dom.getComponentRect(commentOptionEl, (res) => { + if (res && res.size) { + const { top, left, width } = res.size; + // 计算菜单位置:在触发元素下方,右侧对齐 + this.dropdownMenuTop = top; + } + }); + } + // #endif + + } catch (error) { + console.error('getDropdownPosition error:', error); + } + }, // 处理下拉菜单项点击 handle_dropdown_item_click(e) { if (!app.globalData.is_single_page_check()) { @@ -184,7 +224,7 @@ /* 下拉菜单样式 */ .dropdown-menu { /* #ifndef APP-NVUE */ - position: absolute; + position: fixed; /* #endif */ /* #ifdef APP-NVUE */ position: fixed; @@ -195,8 +235,6 @@ border: 1rpx solid #e5e5e5; min-width: 160rpx; z-index: 9999; - top: 100%; - right: 0; margin-top: 8rpx; padding: 10rpx 0; }