【问题标题】:Ionic AlertController and HTML codeIonic AlertController 和 HTML 代码
【发布时间】:2017-11-03 16:55:27
【问题描述】:

嗨,你想要这样的东西,并将 css 分配给每个 div 和地址块。可以吗???

let alert = this.alertCtrl.create({
            title: 'Contact Us',
            subTitle: `
                <div class="address-block pp-notes-row">

                    <address></address>
                </div>
            `,
            buttons: ['OK'],
            cssClass: `
                .alert-wrapper {
                    width: 100%
                }

                .address-block {
                    text-align: left;
                }
            `
        });
        alert.present();

【问题讨论】:

  • 尝试使用自定义 html/css 的弹出框 ;)

标签: ionic-framework ionic2


【解决方案1】:

你可以这样做

let alert = this.alertCtrl.create({
  title: '<h1 class="c-no-margin winner-alert-title">Congratulations!</h1>',
  message: '<div>' +
  '<p class="c-no-margin">You are the WINNER, now please submit your details to your favourite celebrity and get video call.</p>' +
  '</div>',
  buttons: [
    {
      text: 'Select Celebrity',
      handler: () => {
        this.navCtrl.push("CelebrityList");
      }
    }
  ]
});
alert.present();

【讨论】:

  • 很好的答案,我不知道你能做到这一点
  • chrome 改变了它的政策,我的 html 被剥离了,我收到了:WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).
  • @santeko:警告不是来自浏览器,它是由 ionic 在其上构建的 angular 生成的。当您的 HTML 包含与号、实体和其他可被利用的字符/标签时,您可能会得到它。
  • 这是一个非常简单的解决方案。谢谢。
猜你喜欢
  • 1970-01-01
  • 2018-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多