账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    ionic2 jpush插件 打开通知消息后 跳转页面问题
    57
    0
     onOpenNotification = function (event) {
           this.events.publish('GET_MESSAGE');    
            })
    
    

    //这段是在app.components.ts

       this.event.subscribe('GET_MESSAGE', () => {
            this.rootPage = MsgPage;
        })
        
        这样始终不行,请问为什么?
    
    
    5
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 无就将法 普通会员 1楼

      在使用ionic2的jpush插件打开通知消息后,如何解决页面跳转问题,以下是一些可能的解决方案:

      1. 使用路由管理器:你可以使用ionic2的路由管理器(如$state服务)来管理页面的跳转。在你的服务中,你可以定义一个方法来处理跳转,然后在你的组件中调用这个方法。

      ```typescript import { Injectable } from '@angular/core'; import { Router, Navigate } from '@angular/router';

      @Injectable({ providedIn: 'root' }) export class UserService { navigateToAnotherPage() { Navigate('/another-page'); } } ```

      1. 使用浏览器的localStorage:你可以使用浏览器的localStorage来保存页面的跳转状态,然后在你的组件中读取这个状态。

      ```typescript import { Injectable } from '@angular/core'; import { Router, Navigate } from '@angular/router';

      @Injectable({ providedIn: 'root' }) export class UserService { constructor(private router: Router) {}

      navigateToAnotherPage() { localStorage.setItem('pathToAnotherPage', '/another-page'); this.router.navigate(['/another-page']); } } ```

      1. 使用全局导航模式:如果你的app是一个大型应用,你可能需要使用全局导航模式来管理页面的跳转。你可以设置一个全局的路由管理器,然后在你的组件中调用这个路由管理器。

      ```typescript import { Injectable } from '@angular/core'; import { Router, Navigate } from '@angular/router'; import { Location } from '@angular/common';

      @Injectable({ providedIn: 'root' }) export class UserService { constructor(private router: Router, private location: Location) {}

      navigateToAnotherPage() { this.router.navigate(['/another-page']); } } ```

      以上这些方法都可以帮助你解决在打开通知消息后如何解决页面跳转问题。选择适合你的方法,根据你的具体需求来实现。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部