Styling ionic 2 toast

前端 未结 9 2184
深忆病人
深忆病人 2021-02-05 07:32

Is there any way to style the text message within an ionic 2 toast?

I have tried this:

9条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 07:58

    First, import toast controller from ionic-angular and make object of that in constructor.

    import { ToastController } from "ionic-angular";
    
    constructor(private _tc: ToastController) {
    }
    

    After that wherever you want to show your toast message write that.

    let options = {
      message: "Your toast message show here",
      duration: 3000,
      cssClass: "toast.scss"
     };
    
    this._tc.create(options).present();
    

    Here is my scss:

    .toast-message {
      text-align: center;
    }
    

    Or you can check best example from this link. I think it will help you. :)

    Or else check the answer on this link.

提交回复
热议问题