mounted: function() { //使用keep-alive時可以放在activated內 if (window.history && window.history.pushState) { history.pushState(null, null, document.URL); window.addEventListener('popstate', this.listenBack, false); } }, methods: { listenBack() { if (true) { //必須有,否則可能無法關閉 //這個可以關閉安卓系統的手機 document.addEventListener('WeixinJSBridgeReady', function() {
WeixinJSBridge.call('closeWindow');}, false); //這個可以關閉ios系統的手機,順序不能改變 WeixinJSBridge.call('closeWindow'); } }, beforeRouteLeave(to, from, next) { window.removeEventListener('popstate', this.listenBack, false); }