ionic-framework - Ionic 3 侧边栏添加徽章通知不起作用
问题描述
我正在为我的应用程序侧边栏使用 * *Ionic 3 - 徽章**。我添加徽章时遇到了一些冲突,但没有显示任何人知道如何在侧栏中显示徽章谢谢
我的代码部分
应用程序.html
<ion-list class="user-list" >
<button ion-item menuClose class="text-1x" *ngFor="let menuItem of appMenuItems" (click)="openPage(menuItem)" >
<ion-icon item-left [name]="menuItem.icon" style="color: black; " ></ion-icon>
<span ion-text style="color: black; border-bottom: none;">{{menuItem.title}}</span>
<ion-badge">{{p.badgeCount}}</ion-badge>
</button>
</ion-list>
app.component.ts
export interface MenuItem {
title: string;
component: any;
icon: string;
buttonName:string;
}
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = SigninPage;
selectedTheme: String;
appMenuItems: Array<MenuItem>;
constructor(public platform: Platform, private settings: SettingsProvider, private master: master) {
this.settings.getActiveTheme().subscribe(val => this.selectedTheme = val);
this.appMenuItems = [
{title: 'Home', component: HomePage, icon: 'ios-home-outline'},
{title: 'Notification', component: CheckoutPage, icon: 'ios-basket-outline',buttonName: 'badgeNumber ',},
];
}
解决方案
我爱我的问题
我改变这个 <ion-badge>{{menuItem.badgeCount}}</ion-badge>
app.component.ts
export interface MenuItem {
title: string;
component: any;
icon: string;
buttonName:string;
}
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = SigninPage;
selectedTheme: String;
appMenuItems: Array<MenuItem>;
constructor(public platform: Platform, private settings: SettingsProvider, private master: master) {
this.settings.getActiveTheme().subscribe(val => this.selectedTheme = val);
this.appMenuItems = [
{title: 'Home', component: HomePage, icon: 'ios-home-outline'},
{title: 'Notification', component: CheckoutPage, icon: 'ios-basket-outline',badgeCount: '5 ',},
];
}
应用程序.html
<ion-list class="user-list" >
<button ion-item menuClose class="text-1x" *ngFor="let menuItem of appMenuItems" (click)="openPage(menuItem)" >
<ion-icon item-left [name]="menuItem.icon" style="color: black; " ></ion-icon>
<span ion-text style="color: black; border-bottom: none;">{{menuItem.title}}</span>
<ion-badge>{{menuItem.badgeCount}}</ion-badge>
</button>
</ion-list>
推荐阅读
- sql - 将 NULL 视为最大可能值
- javascript - 如何滚动以生成本机 javascript?
- pyspark - 将 df.show() 的内容保存为 pyspark 中的字符串
- matlab - MATLAB 神经网络中不同长度的输入
- go - Kafka 生产者意外行为
- sql - 如何使用 SQL 合并与一个空的整个提取行
- php - 在 laravel 中生成 url
- c++ - 当我将两个矩阵相减时,C++ 中的重载运算符 (<<) cout 不起作用
- php - 如何在Php中减去多维数组中的所有列值?
- android - 如何使用 SetMaxVideoDuration 录制视频