场景:webview加载主脚手架vue cli页面A,然后跳转到外部单页面B,然后B中的某些按钮点击可以跳转会A的某些页面,比如登录页,地址页。
问题1:如何加载新的A页面,通过以下方式加载本地A页面的某个page报错。
this.webviewController.loadUrl($rawfile("dist/index.html")+"?_ijt=b8vf3sr3gfl35bglkehadnvjei#/mine")
问题2:以什么方式加载A页面可以满足按原push方式依次返回,如A-B-A后依次再返回。
问题一:使用loadUrl加载本地资源时,可使用resources协议,适用Webview加载带有"\#"路由的链接,并且带入参数。
相关文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-webview-V5\#loadurlhttps://developer.huawei.com/consumer/cn/doc/harmonyos-faqs-V5/faqs-arkweb-45-V5
问题二:在返回事件触发时进行判断,可按照历史栈后退。
相关文档:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-custom-component-lifecycle-V5\#onbackpress
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-webview-V5\#backward