1.在公共js,如common.js里封装:
function onBridgeReady() {
WeixinJSBridge.call('hideOptionMenu')
}
export function hideWxMenu() {
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()
}
}
2.在封装的公共头部组件,如Header.vue引入:
import { hideWxMenu } from '@/utils/common';
created(){
hideWxMenu()
},
注:全局app.vue引入,只会在首页生效。