富贵资源网 Design By www.hznty.com

废话不多说了,直接给大家贴代码了,具体代码如下所示:

/**
 * Created by wuyakun on 2017/5/23.
 */let wxUtils = {};
/**
 * 是否开启右上角Menu
 * @param open
 */
wxUtils.optionMenu = function (open = true) {
 if (open) {
  openOptionMenu();
 } else {
  disabledOptionMenu();
 }
};
/**
 * 是否禁用右上角
 */
function disabledOptionMenu() {
 if (typeof WeixinJSBridge === "undefined") {
  if (document.addEventListener) {
   document.addEventListener('WeixinJSBridgeReady', onBridgeReady(true), false);
  } else if (document.attachEvent) {
   document.attachEvent('WeixinJSBridgeReady', onBridgeReady(true));
   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(true));
  }
 } else {
  onBridgeReady(true);
 }
}
/**
 * 开启menu
 */
function openOptionMenu() {
 if (typeof WeixinJSBridge === "undefined") {
  if (document.addEventListener) {
   document.addEventListener('WeixinJSBridgeReady', onBridgeReady(false), false);
  } else if (document.attachEvent) {
   document.attachEvent('WeixinJSBridgeReady', onBridgeReady(false));
   document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(false));
  }
 } else {
  onBridgeReady(false);
 }
}
function onBridgeReady(disable = true) {
 if (typeof WeixinJSBridge !== "undefined") WeixinJSBridge.call(disable "htmlcode">
export default class BaseComponent extends React.Component {
 componentDidMount() {
  try {
   //如果存在location说明是路由Component
   if (this.props.location) {
    // 全部禁用分享,想要分享自己开
    wxUtils.optionMenu(false);
   }
  } catch (e) {
   // console.log(e);
  }
 }
}

我写在了Base里面,主要是wxUtils.optionMenu(false);这一句

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com