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

/**
 * 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);这一句

标签:
react,js,微信复制链接,分享,禁止隐藏右上角菜单

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com