美文网首页
小程序嵌套的h5页面分享

小程序嵌套的h5页面分享

作者: tenro | 来源:发表于2021-01-15 15:02 被阅读0次

    html

    <view>
          <web-view src="{{ redirectUrl }}"></web-view>
    </view>
    

    js

    Page({
        data: {
            redirectUrl: '',
            title: '',
        },
    
    /**
     * 生命周期函数--监听页面加载
     */
        onLoad: function (options) {
            _this.setData({
                redirectUrl: options.redirectUrl,
                title: options.title
            })
        },
    
    
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
        onReady: function () {
            wx.setNavigationBarTitle({
                title: this.data.title
            });
        },
    
    /**
     * 用户点击右上角分享
     */
        onShareAppMessage: function (options) {
            const _this = this;
            let share = {
                title: `分享文章`,
                path: '/pages/web-view/h5/index?redirectUrl=' + this.data.redirectUrl + '&title=' + this.data.title
            };
            return share;
        }
    })

    相关文章

      网友评论

          本文标题:小程序嵌套的h5页面分享

          本文链接:https://www.haomeiwen.com/subject/cdkwaktx.html