微信頁面開發的一些經常使用操做(工做記錄)

1.關閉當前網頁窗口微信

wx.closeWindow();

2.批量隱藏功能按鈕app

wx.hideMenuItems({
   menuList: ["menuItem:share:timeline", "menuItem:copyUrl", "menuItem:share:appMessage", "menuItem:share:qq", "menuItem:share:weiboApp", "menuItem:favorite", "menuItem:share:facebook", "menuItem:share:QZone", "menuItem:editTag", "menuItem:delete", "menuItem:copyUrl", "menuItem:originPage", "menuItem:readMode", "menuItem:openWithQQBrowser", "menuItem:openWithSafari", "menuItem:share:email", "menuItem:share:brand"] // 要隱藏的菜單項,只能隱藏「傳播類」和「保護類」按鈕,全部menu項見附錄3
});

3.禁用微信分享按鈕ide

<script>
	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();
	}
</script>

4.隱藏微信網頁右上角的按鈕(分享、收藏等功能按鈕,與第三點實現效果一致)code

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
	// 經過下面這個API批量隱藏功能按鈕
	WeixinJSBridge.call('hideOptionMenu');
});

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
	// 經過下面這個API批量顯示功能按鈕
	WeixinJSBridge.call('showOptionMenu');
});
相關文章
相關標籤/搜索