我正在尝试为网络和设备使用相同的html,并且我需要显示/隐藏web html或设备html。
Ionic 4中的showWhen和hideWhen指令在哪里?如果它们已经消失,它们会被其他东西取代吗?
截至目前我所能找到的只是some test page,但这并没有多说。
将我的应用程序升级到离子4我使用这个替代https://ionicframework.com/docs/utilities/platform来显示基于设备操作系统的正确按钮,它工作得很好并且非常容易实现:
import { Component, OnInit} from '@angular/core';
import { Platform } from '@ionic/angular';
@Component({
selector: 'update-password',
templateUrl: './update-password.component.html'
})
export class UpdatePasswordComponent implements OnInit {
constructor(
public platform: Platform
) { }
<ion-header>
<ion-toolbar>
<ion-title>Update Password</ion-title>
<ion-buttons slot="start">
<ion-button (click)="dismiss()">
<ion-text color="primary" *ngIf="platform.is('ios')">Cancel</ion-text>
<ion-icon name="md-close" *ngIf="!platform.is('ios')"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
是的,Ionic 4有这些指令;
ion-hide-when
和
ion-show-when
例如,如果你只想在android中显示;
<ion-show-when platform="android">
stuff
</ion-show-when>
显然,这些指令刚刚从上一个测试版中的Ionic 4中删除。看到这个link