【问题标题】:Changing styles and text modification of alert controller in ionic 2在 ionic 2 中更改警报控制器的样式和文本修改
【发布时间】:2018-11-10 00:40:50
【问题描述】:

实际上我的警报控制器“标题”太长了,所以我想调整文本的大小,然后我添加了 Css 类,然后尝试通过为其提供字体大小来更改 SASS 中的样式,不幸的是没有用,按钮文本是大写。那么无论如何要更改文本的字体大小,按钮颜色和大小并将按钮文本更改为小写?

我的打字稿文件

import { IonicPage,AlertController} from 'ionic-angular';
import { Component,ViewChild } from '@angular/core';
import 'rxjs/add/operator/toPromise';

@IonicPage()
@Component({
  selector: 'page-kpi',
  templateUrl: 'kpi.html',
})
export class KpiPage {

  @ViewChild(Nav) nav: Nav;
  temp2:any;
  lastUpdate:any;

 constructor(
    private alertCtrl: AlertController,
    public menuCtrl : MenuController,


   ) {
      this.platform.ready().then(() => {

              this.refreshbutton();

      }
    });


refreshbutton(){

    this.getSession();

  if(this.offline == true)
    {
       this.offlineRefreshAlert();
    }  
   else{
    let alert = this.alertCtrl.create({
            title: 'Do you really want to refresh the widgets?',
            message: 'Refresh process will take time to complete.',
            cssClass: 'alertLogCss',
            buttons: [
              {
                text: 'Cancel',
                role: 'cancel',
                handler: () => {
                  alert = null;
                }
              },
              {
                text: 'Refresh now',
                 handler: () => {
                   if(this.online == true){
                      this.refreshdata(this.result.sid);
                      this.loadingrefreshdashboard();
                   }
                   if(this.offline == true){

                      this.offlineRefreshAlert();
                   }



                 }
               }
            ]
          });
          alert.present();
        }
    }

}

我的 SASS(CSS) 文件

.alertLogCss{
  background-color: white;
  color: red;
  font-size: 4px;
  button{
      color: red;
      font-size: 5px;
  }
}

【问题讨论】:

  • 你可以使用 codepen/jsfiddle/plunker 等创建一个工作代码 sn-p 吗?回答会更快。
  • 弹出窗口在哪里?我在输出中看不到。
  • 我觉得在 codepen 或 jsfibble 中添加警报控制器太难了,警报控制器在主应用程序模块中

标签: css angular ionic-framework sass ionic2


【解决方案1】:

你必须从那个页面的 scss 块中添加 css

.alertLogCss{
    background-color: white;
    color: red;
    font-size: 4px;
    button{
        color: red !important;
        font-size: 10px;
        text-transform: lowercase !important;
    }
  }

放入app.scss

【讨论】:

  • app.scss 上已经有....可以在 alertcontroller 中添加图片或图标吗?
  • 你可以这样写消息属性:'
    uploads/category/category_logo/thumbnail/…">刷新过程需要时间来完成。
    ',
  • 实际上直接将文本转换为小写有没有办法让首字母大写,如“Refresh Now”.....
  • 为此,您可以编写 text-transformation = "capitalize !important"
猜你喜欢
  • 2021-06-09
  • 2017-06-18
  • 1970-01-01
  • 1970-01-01
  • 2015-08-17
  • 1970-01-01
  • 2020-09-04
相关资源
最近更新 更多