微信小程序 webview 打开外部网页无法返回本页面, 带参传地址不成功?

问题1 :使用webview打开外部页,小程序页面被新打开的页面全部覆盖, 无法返回页面问题。

解决办法:  添加一个按钮,点按钮将外部文件地址传到一个新的页面,在新页面打开还可以返回到本页面。

问题2:从页面里带参跳转时URL地址没完全传过去。

比如需要传过去的参数是:

https://www.cnblogs.com/season/huang/runtime.shtm?prjId=183&picId=886&rand=0.957680391513647

结果传过去的参数是:

https://www.cnblogs.com/season/huang/runtime.shtm

解决办法:需要再传值的时候使用 encodeURIComponent 将url的地址转码,在使用地址的时候 decodeURIComponent 解码

当需要编码URL中的参数的时候,需要使用encodeURIComponent转码 , decodeURIComponent()解码。

对于字符转码有很多种方式:escape、encodeURI和encodeURIComponent

encodeURIComponent 编码 和decodeURIComponent()解码  用于对url 的地址编码转义。

猜你喜欢

转载自blog.csdn.net/X_lizhu93/article/details/88526516