onLaunch 当uni-app 初始化完成时触发(全局只触发一次)

  1. onLaunch() {
  2. // 第一次进入系统,由于Router插件不能拦截,由以下实现登录鉴权
  3. if(window.performance.navigation.type === 0) {
  4. // performance.navigation.type = 0 表示用户不是刷新操作(刷新操作 = 1)
  5. // routerBefore(this.$Route as totalNextRoute, this.$Route as totalNextRoute);
  6. this.$Router.replace({ path: this.$Route.path, query: this.$Router.query})
  7. }
  8. console.log('App Launch')
  9. }

参考资料

uni-app 官方文档:应用生命周期