首页 > 编程知识 正文

小程序webview缓存清理,小程序webview分享到朋友圈

时间:2023-05-03 16:02:38 阅读:209395 作者:4800

一、webview是什么?
开发文档:https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html
它其实就是也没的承载容器,可以在小程序中承载h5也页面。
二、使用
因为会多次使用到,所以可以将它直接封装。
我这里使用了taro,其实原来都是一样的。

在页面初始化的时候从URL中获取地址,相当于在小程序中的onLoad中获取。

componentDidMount() { const { url, code,orderId,token } = this.$router.params; let link = url ? decodeURIComponent(url) : urls[code || ''] || '';//这是解析具体看需求 link = orderId? `${link}?orderId=${orderId}&token=${token}`: link//携带token具体看需求 this.setState({ link }); } render() { if (!this.state.link) { return null; } return <WebView src={this.state.link}></WebView>; }}

在使用的地方进行跳转,跳转时携带URL。

wx.navigateTo({url: `/pages/webview/index?url=${Url}`})

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。