小编Dak*_*Dak的帖子

如何更改Ionic2中Alert中按钮的颜色

是否可以在Ionic2中更改Alert(Ok,Cancel)按钮的颜色?我们可以使用cssClass属性为按钮赋予颜色吗?

.buttonCss{
    button{
        color:#e74c3c !important;
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码为Ok和Cancel按钮提供了相同的颜色,如下图所示 在此输入图像描述

但是我需要得到以下结果(两个按钮都是不同的颜色), 在此输入图像描述

任何帮助表示赞赏......!

编辑1:添加showAlert()功能

    showAlert(title, message, yesHandler, noHandler, caller) {
    let alert = this.alertCtrl.create({
        title: title || "Please Confirm",
        message: message,
        cssClass:'buttonCss',
        buttons: [
            {
                text: 'Exit',
                handler: () => yesHandler(caller)
            },
            {
                text: 'Cancel',
                role: 'cancel',
                handler: () => noHandler(caller)
            }
        ]
    });
    alert.present();
}
Run Code Online (Sandbox Code Playgroud)

css typescript ionic2 ionic3 angular

4
推荐指数
1
解决办法
4164
查看次数

问题"离子cordova build android --prod --release"

我使用Ionic2创建了一个聊天应用程序.当我尝试使用生产构建时ionic cordova build android --prod --release,我收到以下错误.

    Error: ./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:9341:17)
    at assignContextualParameterTypes (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:42959:28)
    at checkExpression (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:42898:42)
    at checkExpressionCached (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:42779:38)
    at checkReturnStatement (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:45418:54)
    at checkSourceElement (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:46763:28)
    at Object.forEach (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:1506:30)
    at checkBlock (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:44563:16)
 @ ./node_modules/rxjs/observable/bindCallback.js 2:32-68
 @ ./node_modules/rxjs/add/observable/bindCallback.js
 @ ./node_modules/rxjs/Rx.js
 @ ./src/providers/apis/apis.ts
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts,./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:9341:17)
    at assignContextualParameterTypes (C:\Users\cool\Desktop\Chat\SideMenu\node_modules\typescript\lib\typescript.js:41652:25)
    at …
Run Code Online (Sandbox Code Playgroud)

deployment observable typescript ionic2 angular

3
推荐指数
1
解决办法
651
查看次数

标签 统计

angular ×2

ionic2 ×2

typescript ×2

css ×1

deployment ×1

ionic3 ×1

observable ×1