vue微信公众号关闭分享和关闭复制按钮

方法一

 function onBridgeReady() {
                WeixinJSBridge.call('hideOptionMenu');
            }
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                    document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                }
            } else {
                onBridgeReady();
            }

方法二

先安装weixin-js-sdk

npm install weixin-js-sdk

引入

import wx from ‘weixin-js-sdk’;

使用

this.$axios.post('/weixin/get',{'url':location.href.split('#')[0]}).then((response)=> {
                wx.config({
                    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                    appId: response.appid, // 必填,公众号的唯一标识
                    timestamp: response.timestamp, // 必填,生成签名的时间戳
                    nonceStr:  response.nonceStr, // 必填,生成签名的随机串
                    signature:  response.signature,// 必填,签名
                    jsApiList: [ 'hideMenuItems'] // 必填,需要使用的JS接口列表
                });
                wx.ready(function () {
                    wx.hideMenuItems({
                        menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline', 'menuItem:share:qq', 'menuItem:share:QZone', 'menuItem:openWithSafari', 'menuItem:openWithQQBrowser', 'menuItem:favorite','menuItem:share:facebook','menuItem:share:weiboApp','menuItem:copyUrl','menuItem:openWithQQBrowser','menuItem:openWithSafari'],
                    });
                    wx.hideAllNonBaseMenuItem();
                });

                wx.error(function (res) {
                    // alert('wx.error: '+JSON.stringify(res));

                });
            })

公众号文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#2
微信返回码说明:https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Global_Return_Code.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值