// set up app destroyed handler // https://github.com/vuejs/vue-router/issues/2639 // app被destroyed时候,会$emit ‘hook:destroyed’事件,监听这个事件,执行下面方法 // 从apps 里将app移除 app.$once("hook:destroyed", () => { // clean out app from this.apps array once destroyed const index = this.apps.indexOf(app); if (index > -1) this.apps.splice(index, 1); // ensure we still have a main app or null if no apps // we do not release the router so it can be reused if (this.app === app) this.app = this.apps[0] || null; });