小程序内webivew在页面load之前可以设置title,页面load后就不能再设置title?

小程序 文章 2022-02-09 15:00 850 0 全屏看文

AI助手支持GPT4.0

小程序内webivew在页面load之前可以设置title,页面load后就不能再设置title?The webivew in the applet can set the title before the page is loaded, but cannot set the title after the page is loaded?

小程序内webivew在页面load之前可以设置title,页面load后就不能再设置title?

我们当前的页面需要根路由去动态设置title,如题所述,小程序再这块有什么办法或者api去设置吗

Our current page needs the root route to dynamically set the title. As mentioned in the title, is there any way or API for the applet to set it

回答:

圣殿骑士:

webview页面 默认加载网页的title哦

不过加载好,你还是可以通过wx.setNavigationBarTitle 修改


砥行:使用 wx.setNavigationBarTitle可以再将webivew的网页title重新覆盖回来吗?早上试了这个方法,没生效,我再试试。感谢
小黎:

webview页面标题是网页的标题,你想动态改变就得动态改变你网页的标题

小程序内部的页面标题才是属于小程序的,通过wx.setNavigationBarTitle更改


砥行:现在在webivew中页面未加载完毕之前,修改document.title是响应的;等页面加载完毕,等待1,2s(测试),再修改document.title时,无任何反应;使用wx.setNavigationBarTitle修改,也无任何反应。
小黎:看下你的代码
微喵网络:

webview页面会自动加载网页的标题做title

砥行:嗯,目前表象是这样,我们的页面是,在业务中去调整title,浏览器中是正常可以的,就想知道,小程序需要怎样才能和浏览器一样,动态设置
砥行:还是小程序内,等webview加载完毕后,是不允许调整title的?

-EOF-

AI助手支持GPT4.0