【发布时间】:2019-03-26 05:06:33
【问题描述】:
我有两个应用程序:一个是针对服务提供商的,另一个是针对普通用户的(有点像抓斗司机应用程序)。两者都非常相似(除了一些仅为服务提供商专有的页面),其中一项功能是消息传递和查询。两个应用程序的消息传递实现非常相似。
我有一个信使页面,其中有两个选项卡:聊天和查询。问题来了,当我浏览用户应用程序中的选项卡时,在我看来它正在将页面添加到堆栈中。流程是这样的:
- 我打开应用程序,主页正在显示
- 我打开信使页面,正在显示聊天标签
- 我点击查询选项卡,查询选项卡正在显示
- 我按下返回按钮,它会返回聊天标签(应该返回主页)
但是,当两个应用程序中的实现相同时,它在服务提供商应用程序上运行良好。适用于与上述相同的情况,它在服务提供商应用程序中以这种方式工作(我希望它的工作方式):
- 我打开应用程序,主页正在显示
- 我打开信使页面,正在显示聊天标签
- 我点击查询选项卡,查询选项卡正在显示
- 按返回键,返回首页
以下是代码,因为两个应用都使用相同的代码,所以我将它们粘贴一次:
messenger.ts:
<ion-tabs>
<ion-tab-bar slot="top">
<ion-tab-button tab="chats">
<ion-label><strong>Chat</strong></ion-label>
</ion-tab-button>
<ion-tab-button tab="inquiries">
<ion-label><strong>Inquiries</strong></ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
mesenger.module.ts:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { MessengerPage } from './messenger.page';
const routes: Routes = [
{
path: 'tabs',
component: HealthMessengerPage,
children: [
{
path: 'chats',
loadChildren: '../chats/chats.module#ChatsPageModule'
},
{
path: 'inquiries',
loadChildren: '../inquiries/inquiries.module#InquiriesPageModule'
},
]
},
{
path: '',
redirectTo: 'tabs/chats',
pathMatch: 'full'
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [MessengerPage]
})
export class MessengerPageModule {}
我不知道我哪里做错了。有人可以帮忙吗?
更新
我似乎无法找出造成这种情况的原因,所以我将所有内容复制到一个新的项目文件中,然后 现在工作正常。
【问题讨论】:
-
不确定但可能与此错误有关github.com/ionic-team/ionic/issues/15216
-
您是否提供了
messenger.html而不是messenger.ts? -
@IanP。它们是 ts 文件。即使代码完全相同,它们在其他应用程序中也能正常工作
-
我认为@CyrilHanquez 是对的,这可能是一个错误。
-
最后,我将整个应用程序复制到了一个新的 ionic 项目中,它工作正常。
标签: angular ionic-framework ionic4