zoukankan      html  css  js  c++  java
  • uni-app 第三方应用中调起微信分享

    最近做项目的时候遇到一个问题

    在APP中的某个单独的小项目中使用uni-app写的项目调起微信分享

    单独引入jweixin-1.6.0.js在需要分享的页面中时,

    页面会报错,导致原有的数据都没有展示出来;

    可以使用第三地方组件

    npm install jweixin-module --save

    安装微信分享模块

    安装完成后你会得到一个jweixin-module 的包,

    然后

    import wx from "@/jweixin-module/jweixin-module/lib/index.js"

    在页面中引入模块

    wxShare(config, news, users){

      var _this = this;
      //微信分享
      wx.config({
        appId: config.appId,
        timestamp: config.timestamp,
        nonceStr: config.nonceStr,
        signature: config.signature,
        debug: config.debug,
        jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "chooseImage",
        "uploadImage", "hideMenuItems", "closeWindow"
        ] // 所有要调用的 API 都要加到这个列表中
      });
      wx.ready(function() {
      // 在这里调用 API
      wx.hideMenuItems({
        menuList: ['menuItem:copyUrl', 'menuItem:favorite', 'menuItem:originPage', 'menuItem:openWithQQBrowser','menuItem:openWithSafari', 'menuItem:share:email', 'menuItem:share:qq', 'menuItem:share:weiboApp','menuItem:share:QZone'
        ] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3,分享朋友:'menuItem:share:appMessage',分享朋友圈:'menuItem:share:timeline'
      });

      wx.onMenuShareTimeline({ //分享到朋友圈
        *******
      });

      wx.onMenuShareAppMessage({ //分享给朋友
        ****
      });
      });
    ;

    注意:

    wx.config不要放到wx.ready方法里面

  • 相关阅读:
    零零碎碎
    MFC入门--显示静态图片及调用本地软件
    Python版本OpenCV安装配置及简单实例
    用星星画菱形--Java
    pycharm IDE在导入自定义模块时提示有错,但实际没错
    Cmd使用方式--命令行运行程序
    cv2 & PIL(pillow)显示图像
    C++命令行多文件编译(g++)
    MNIST多图显示--Python练习
    visual studio 2017--括号自动补全
  • 原文地址:https://www.cnblogs.com/yeziyou/p/13740374.html
Copyright © 2011-2022 走看看