小程序右上角转发分享web-view页面(备份前端网)
如果出现开发版小程序已过期,请在开发者工具重新扫码的话;
让那人重新扫一下开发工具预览!
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<web-view src="{{url}}"></web-view> /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options); var id = options.id; var url = options.url; var url = `${url}?id=${id}`; console.log(url); this.setData({ url: url, hurl: options.url, id: options.id }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function (e) { console.log(e); var webViewUrl = e.webViewUrl; console.log(webViewUrl); var url = this.data.hurl; var id = this.data.id; console.log(url); console.log(id); return { title: '春稻田', path: `/pages/webView/index?url=${url}&id=${id}`, success: function (res) { // 转发成功 console.log("转发成功:" + JSON.stringify(res)); }, fail: function (res) { // 转发失败 console.log("转发失败:" + JSON.stringify(res)); } } }
这里面要注意得是onShareAppMessage里面得path是当前小程序得目录;而且穿得参数要保证onload里面传入web-view里面得一样,要不就是页面未显现