vue.js - One-time redirect upon detecting Nuxt PWA in standalone mode
问题描述
I'm trying to achieve this, but no luck.
Here's the plugin. All three console logs are running correctly, including the 3rd-party platform.js functionality.
It's just the this.$route.router.go('/ourmenu')
that isn't doing the redirect. I'm wondering if this is the right way to redirect in Nuxt, or if it needs to be done differently.
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
window.onNuxtReady(() => {
console.log('onNuxtReady!');
console.log('platform test: ');
console.log(platform.os.toString())
if (platform.os.toString().includes('iOS') == true && window.navigator.standalone == true) {
this.$route.router.go('/ourmenu');
} else if (window.matchMedia('(display-mode: standalone)').matches) {
this.$route.router.go('/ourmenu');
} else {}
})
EDIT: I've also tried this.$router.push('/ourmenu')
and context.redirect(
${config.url}/ourmenu)
...Still a no go.
Any suggestions?
Thanks!
解决方案
找到了一个更简单的解决方案: Web App Manifest: start_url
推荐阅读
- c - C 中从 1 到 N 的内存分配
- mysql - Mysql `OR` 条件不适用于 JOIN
- spring - 如何在 Spring 4.1.7 中将模拟注入自定义 ConstraintValidator?
- encryption - RSA 在加密句子时如何工作?
- mysql - 显示订购的所有产品名称列表以及客户的名字和姓氏
- nginx - 如何通过入口注释将流量重定向到我的 Web 服务?
- git - Azure Devops 开发掌握合并问题
- node.js - 何时何地使用 Firebase admin.app().delete()?
- laravel - 从 Laravel 5.8 中的抽象类的静态方法发送通知?
- java - 为许多组件有效地存储布尔事件的简短历史