zoukankan      html  css  js  c++  java
  • 小程序分享H5页面

    1、在要分享的按钮上写一个跳转

    <navigator url="../invite1/invite1">
      <button class="invite_btn">立即邀请</button>
    </navigator>
    2、再新建一个页面invite1,新建一个web-view

    wxml页面

    <web-view src="{{shareUrl}}"></web-view>
    js页面

    定义一个变量,并对其赋值。

    data:{
      shareUrl: null
    },
    onLoad: function (options) {
      var that = this
      that.setData({
        shareUrl: "http://test.meetfit.com.cn/share/active/?userId=" + id + "&userName=" + nickname
      })
    },
    

      

    3、分享js
    onShareAppMessage: function (res) {
      var that = this
      if (res.from === 'button') {
        // 来自页面内转发按钮
        console.log(res.target)
      }
      return {
        title: '分享H5',
    //这一点很重要哦,小程序只能打开自己的页面,所以需要本地的地址+webViewUrl的地址才行。
        path: "/pages/mine/invite1/invite1?url=" +res.webViewUrl,  
        imageUrl: "",
        success: (res) => {
          if (res.data.code == 0) {
            wx.showToast({
            title: '发送邀请好友成功',
            icon: 'success',
            duration: 2000
          })
        } else {
         wx.showToast({
          title: res.data.message,
          icon: 'none',
          duration: 2000
        })
       }
      },
        fail: (res) => {
        console.log("转发失败", res);
        }
      }
    }
    

      

  • 相关阅读:
    重置mysql数据库密码
    windows下IIS+PHP解决大文件上传500错问题
    ecmobile中IOS版本中界面文字不显示的解决
    linux下重置mysql的root密码
    nginx下rewrite参数超过9个的解决方法
    android模拟器停在Waiting for HOME解决方案
    android模拟器没法通过localhost访问本地服务器的解决
    zend studio导入svn项目后不能代码提示的解决
    排序(1)

  • 原文地址:https://www.cnblogs.com/chengmingxiaowu/p/9766211.html
Copyright © 2011-2022 走看看