dcloudio / dcloudio/uni-app

存在于组件中的uni-notice-bar的text值动态更新后在h5中不会滚动

Open
#5,424 2 comments 0 reactions 1 assignee Claimed by @chouchouji View on GitHub
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

### 发行方式

None

### 具体平台

微信小程序中正常.

下面H5页面都异常.
chrome 135.0.7049.115
HBuilder X 4.57 内置WEB浏览器
Edge 135.0.3179.85

### 开发环境

Windows

### 项目创建方式

HBuilderX

### 依赖版本

HBuilder X 4.57

### 问题描述

在A页面与B页面都引用了MyNotice.vue(A与B均为tabBar页面)
在A页面改变getApp().globalData.notice值后,到B页面中看MyNotice的文本不会滚动也不显示,从开发者工具中查看html元素值是已修改的,两个页面都收到了值变化通知. 只是不显示也不会滚动.
同样,在B页面改变getApp().globalData.notice值时,在A页面也不会滚动.
微信小程序中是正常的.

自定义MyNotice代码
````

export default {
options: {
styleIsolation: 'shared'
}
}

import { ref, onMounted, onUnmounted } from 'vue'

const redraw_count = ref(0);

const noticeText = ref(getApp().globalData.notice);

const onNoticeChanged = (val) => {
noticeText.value = getApp().globalData.notice
console.log("公告改变:"+noticeText.value);
}
onMounted(() => {
uni.$on('notice-changed', onNoticeChanged)
})
onUnmounted(() => {
uni.$off('notice-changed', onNoticeChanged)
})

console.log(getApp().globalData.notice);

.MyNotice {
margin-bottom: 0px;
/* padding: 5px; */

::v-deep .uni-noticebar {
margin-bottom: 0px;
padding: 5px;
}
}
````

### 重现步骤

要先进入过A页面与B页面
如果只进入了A页面,没有进入B
在A中改变值时, 进入B后是正常的

### 期望行为

_No response_

### 实际行为

_No response_

### 截图或录屏

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.