微信开发常用代码
1.获取微信公众号接口
https://open.weixin.qq.com/qr/code?username=jsxc-china
2.判断是否是微信打开
function isWeiXin() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
if (isWeiXin()) {
//yes
} else {
//no
}
3.隐藏微信右上角按钮(分享功能)
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.call('hideOptionMenu');
});
4.显示微信右上角按钮(分享功能)
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
WeixinJSBridge.call('showOptionMenu');
});