赞
踩
官方文档
https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html
该组件 SRC 填写外部链接 url
用
navigator(<navigator url="url"> sdsad</navigator>
)
或者
wx.navigateTo或其它等效页面跳转方法
需登录小程序管理后台配置业务域名。
按照官方流程总结如下步骤
在1的基础上,web-view显示的html文件,需要增加支持微信JSSDK的js代码
代码流程
如
test.html是外部连接显示的内容,点击按钮跳回到微信小程序页面page2(“/page/page2/page2”)
test.html代码
<html> <head> <meta charset="utf-8" /> </head> <body> <button onclick="jump()">测试点击</button> <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> <script> function jump(){ console.log("外部连接"); wx.miniProgram.postMessage({ data: { link: "test" }); } </script> <body> </html>
page2代码
page2.wxml
<web-view src="https://yourWeb.com/test.html" bindmessage="postMessage">
</web-view>
page2.js
主要代码
postMessage:function(options){
console.log("bindmessage",options);
wx.navigateTo({
url: `/pages/page2/page2`,
})
},
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。