HarmonyOS 鸿蒙Next悬浮窗里面,router.pushUrl 提示成功,但是页面并没有真正显示
HarmonyOS 鸿蒙Next悬浮窗里面,router.pushUrl 提示成功,但是页面并没有真正显示
<markdown _ngcontent-rms-c237="" class="markdownPreContainer">
悬浮窗页面里面,调用router.pushUrl
提示成功,url
对应页面的aboutToAppear
也执行了,但是页面并没有显示。
悬浮窗页面示例代码如下:
[@Entry](/user/Entry)
[@Component](/user/Component)
export default struct VoipFloatingPage {
@State now: number = new Date().getTime()
onPageShow(): <span class="hljs-reserved"><span class="hljs-reserved">void</span></span> {
setInterval<span class="hljs-function"><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(() => {
</span></span><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-params"><span class="hljs-keyword">this</span></span></span></span><span class="hljs-function"><span class="hljs-params">.now = </span></span><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-params"><span class="hljs-keyword">new</span></span></span></span><span class="hljs-function"><span class="hljs-params"> Date().getTime()
}, </span></span><span class="hljs-number"><span class="hljs-function"><span class="hljs-params"><span class="hljs-number">1000</span></span></span></span><span class="hljs-function"><span class="hljs-params">)</span></span></span><span class="hljs-function">
}
</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">build</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">()</span></span></span><span class="hljs-function"> {
</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">Column</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">()</span></span></span><span class="hljs-function"> {
</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">Text</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(</span></span><span class="hljs-string"><span class="hljs-function"><span class="hljs-params"><span class="hljs-string">'Voip'</span></span></span></span><span class="hljs-function"><span class="hljs-params"> + </span></span><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-params"><span class="hljs-keyword">this</span></span></span></span><span class="hljs-function"><span class="hljs-params">.now)</span></span></span><span class="hljs-function">
}
.</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">onClick</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(() => {
showToast(</span></span><span class="hljs-string"><span class="hljs-function"><span class="hljs-params"><span class="hljs-string">'Test'</span></span></span></span><span class="hljs-function"><span class="hljs-params">) </span></span><span class="hljs-regexp"><span class="hljs-function"><span class="hljs-params"><span class="hljs-regexp">//</span></span></span></span><span class="hljs-function"><span class="hljs-params"> toast 没有显示
router.pushUrl({ </span></span><span class="hljs-regexp"><span class="hljs-function"><span class="hljs-params"><span class="hljs-regexp">//</span></span></span></span><span class="hljs-function"><span class="hljs-params"> push 进去的页面没有显示
url: </span></span><span class="hljs-string"><span class="hljs-function"><span class="hljs-params"><span class="hljs-string">'pages/voip/SingleAudioCallPage'</span></span></span></span><span class="hljs-function"><span class="hljs-params">
})
.</span></span><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-params"><span class="hljs-keyword">then</span></span></span></span><span class="hljs-function"><span class="hljs-params">(() => {
</span></span><span class="hljs-built_in"><span class="hljs-function"><span class="hljs-params"><span class="hljs-built_in">console</span></span></span></span><span class="hljs-function"><span class="hljs-params">.log(</span></span><span class="hljs-string"><span class="hljs-function"><span class="hljs-params"><span class="hljs-string">'pushUrl success'</span></span></span></span><span class="hljs-function"><span class="hljs-params">)
})
.</span></span><span class="hljs-keyword"><span class="hljs-function"><span class="hljs-params"><span class="hljs-keyword">catch</span></span></span></span><span class="hljs-function"><span class="hljs-params">((e: BusinessError) => {
</span></span><span class="hljs-built_in"><span class="hljs-function"><span class="hljs-params"><span class="hljs-built_in">console</span></span></span></span><span class="hljs-function"><span class="hljs-params">.log(</span></span><span class="hljs-string"><span class="hljs-function"><span class="hljs-params"><span class="hljs-string">'pushUrl error'</span></span></span></span><span class="hljs-function"><span class="hljs-params">, e)
})
voipFloatingWindow!.destroyWindow()
})</span></span></span><span class="hljs-function">
.</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">backgroundColor</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(Color.Green)</span></span></span><span class="hljs-function">
.</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">width</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(</span></span><span class="hljs-number"><span class="hljs-function"><span class="hljs-params"><span class="hljs-number">100</span></span></span></span><span class="hljs-function"><span class="hljs-params">)</span></span></span><span class="hljs-function">
.</span><span class="hljs-title"><span class="hljs-function"><span class="hljs-title">height</span></span></span><span class="hljs-params"><span class="hljs-function"><span class="hljs-params">(</span></span><span class="hljs-number"><span class="hljs-function"><span class="hljs-params"><span class="hljs-number">100</span></span></span></span><span class="hljs-function"><span class="hljs-params">)</span></span></span><span class="hljs-function">
}
}
<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 4px; right: 8px; font-size: 14px;">复制</button>
</markdown>
更多关于HarmonyOS 鸿蒙Next悬浮窗里面,router.pushUrl 提示成功,但是页面并没有真正显示的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS 鸿蒙Next悬浮窗里面,router.pushUrl 提示成功,但是页面并没有真正显示的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
已修饰,也配置了的。
正常启动 SingleAudioCallPage 是没问题的,只是不能从悬浮窗启动
在HarmonyOS鸿蒙系统中,router.pushUrl
成功执行但页面未显示,可能由以下原因造成:
- 路由配置问题:检查路由配置是否正确,确保目标页面已正确注册并在路由表中。
- 悬浮窗权限:确认应用是否有在悬浮窗中显示页面的权限,部分系统或安全软件可能限制此功能。
- 页面生命周期:检查目标页面是否有正确处理生命周期事件,如
onShow
,确保页面被正确渲染。 - 缓存或状态问题:尝试清除应用缓存或重启应用看是否解决问题。
如果问题依旧没法解决请加我微信,我的微信是itying888。
更多关于HarmonyOS 鸿蒙Next悬浮窗里面,router.pushUrl 提示成功,但是页面并没有真正显示的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html