angular - 离子移动应用程序在开发中运行良好,但在生产中运行不佳
问题描述
我正在开发我的第一个离子应用程序。我已经完成了它,当我制作它时它工作得很好
ionic serve --open
或者当我在移动设备上的 Ionic DevApp 上打开它时。
当我创建 .apk 时,几乎所有功能都可以正常工作;但这个不是:
<ion-tab [root]="tab1Root" [enabled]=" _tabs.textToEnableTabs !='AddListPage' " tabTitle="Pending Tasks" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" [enabled]=" _tabs.textToEnableTabs !='AddListPage' " tabTitle="Finished Tasks" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="tab3Root" [enabled]=" _tabs.textToEnableTabs !='AddListPage' " tabTitle="Contact Author" tabIcon="contacts"> </ion-tab>
这段代码检查我们是否在某个组件上,所以如果我们在那个组件上,我们会让标签不可点击。
正如我所说,此功能在开发中完美运行,但在生产环境中无法正常工作,其中选项卡始终可单击。所以[enabled]
标签或条件不能正常工作。我不知道。
哪个可能是问题?
如果它对您有帮助,我有一个服务 ShowTabsService 我在其中创建该属性
//ShowTabsService.ts
textToEnableTabs
我在构造函数上初始化:
"ShowTabsService.ts constructor
constructor()
{
this.textToEnableTabs=""; /*value will change on the addList.ts constructor and on its onDestroy, to make tabs available again*/
}
当我在 AddListPage 的构造函数上时,标签不应该是可点击的,我这样做:
//AddListPage.ts
constructor(
private _viewController:ViewController,
private _tabs:ShowTabsService) {
this._tabs.textToEnableTabs=this._viewController.name; //this will be 'AddListPage' when we are on that component
}
在 ngOnInit 上,当我们离开该组件时,我们通过执行以下操作使选项卡再次可点击:
//AddListPage.ts
ngOnDestroy()
{
this._tabs.textToEnableTabs="";
}
也许这不是最好的方法(我是 Angular 和 Ionic 的新手),但正如我所说,这在开发中是正确的。不是在我安装签名的 APK 时
解决方案
有人在这里向我建议了解决方案
问题是,在这部分代码中:
<ion-tab [root]="tab1Root" [enabled]=" _tabs.textToEnableTabs !='AddListPage' " tabTitle="Pending Tasks" tabIcon="home"></ion-tab>
我依赖于类名,当您在生产环境中构建应用程序时,它们会被缩小,这就是为什么我的代码在开发模式下运行良好但在生产环境中运行良好的原因。
我建议在离子论坛上阅读此主题
推荐阅读
- linux-kernel - 在重新映射的地址范围内分配内存
- python - 如何删除一组字符串的第一项
- r - 关于get_mon_arrivals的R simmer包问题
- javascript - 如何使用 puppeteer 返回新页面?
- python - 单层感知器实现的问题
- node.js - 除了一个 discord.js v12 之外,如何从成员中删除所有角色?
- javascript - 如何将“奇怪的”ESRI Tile XYZ 格式转换为 XYZ
- r - 从第二个数据框 R 添加列和插入信息
- java - java.io.FileNotFoundException:文件:/storage/emulated/0/WhatsApp/Media/.Statuses/xyz.jpg:打开失败:ENOENT(没有这样的文件或目录)
- java - 我对 Java 的方法有疑问,可以给我一些建议吗?