简体   繁体   English

无法从电容器侦听器 (appUrlOpen) 事件 (Nuxt、Vue.js、Vue-Router) 导航应用程序

[英]Failing to navigate App from Capacitor listener (appUrlOpen) event (Nuxt, Vue.js, Vue-Router)

As a first project I have Nuxt, VueJs and Capacitor that fails to route a Firebase dynamic link.作为第一个项目,我有 Nuxt、VueJs 和 Capacitor,它们无法路由 Firebase 动态链接。

The iOS App is setup to accept Associated Domains as works as such. iOS 应用程序设置为接受关联域作为此类工作。

The iOS App opens and fires a Capacitor event 'appUrlOpen', however it fails to navigate when I try initiate router.push() to any valid path eg.('/about') iOS 应用程序打开并触发电容器事件“appUrlOpen”,但是当我尝试将 router.push() 启动到任何有效路径时,它无法导航,例如(“/about”)

Debugging suggests the promise on the push succeeds, however this is not reflected on the simulator.调试提示 promise 推送成功,但是模拟器上没有反映。

I have ensured that the the routes are correct at the time of the push and exhausted all other possibilities to where this may be causing an issue.我已确保在推送时路线是正确的,并用尽了所有其他可能导致问题的地方。

The code below resides in a JS file which is imported as a plugin with nuxt.config.js下面的代码位于一个 JS 文件中,该文件通过 nuxt.config.js 作为插件导入

import { App } from '@capacitor/app';
import Vue from 'vue';
import VueRouter from 'vue-router';

const router = new VueRouter({ routes: [ { path: '/about' }] });

App.addListener('appUrlOpen', data => {
    router.push({ path: '/about' })
      .then(() => console.log('Navigated!'))
      .catch(error => {
      console.log('Error', error);
    });
});

Oddly, a user by the name of Mani Mirjavadi (user:4448220) indirectly answered this question but removed his post a short while ago.奇怪的是,名为 Mani Mirjavadi (user:4448220) 的用户间接回答了这个问题,但不久前删除了他的帖子。 Luckily it was available as a cached resource.幸运的是,它可以作为缓存资源使用。

It appears as if the route needs to route as such below.看起来好像路线需要像下面这样路由。

 window.onNuxtReady(() => {
    App.addListener('appUrlOpen', (event) => {
        window.$nuxt.$router.push('/community')
        })
    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM