【问题标题】:New line on alert message警报消息上的新行
【发布时间】:2018-04-19 20:50:47
【问题描述】:

在 Ionic 3 中是否有使用 Alert 显示新行的方法?

我应该用什么替换'\n'?

doFinalise() {
let confirm = this.alertCtrl.create({
  title: 'Are you sure?',
  message: 'Are these details correct?\n Price ($/L): \n KMs Done: \n Total Spent: \n Fuel Type: \n Date: ',
  buttons: [ etc...

最终,消息将在新行之前显示变量,但现阶段不需要。

【问题讨论】:

    标签: ionic2 ionic3


    【解决方案1】:

    AlertController 可以解析 HTML 标签。所以你可以在这里使用<br/>标签。

    let confirm = this.alertCtrl.create({
      title: `Are you sure?`,
      message: `Are these details correct?<br/> Price ($/L): <br/> KMs Done: <br\> Total Spent: <br\> Fuel Type: <br\> Date: `,
      buttons: [ etc...
    

    或者您可以查看my demo 并尝试使用项目符号或编号。

    let alert = this.alertCtrl.create({
          title: 'Are you sure?',
          message: `
            Are these details correct?
            <ul>
              <li>Price ($/L):</li>
              <li> KMs Done: </li>
              <li>Total Spent: </li>
              <li>Fuel Type:</li>
              <li> Date: </li>
            </ul>
          `,
    

    来源:this forum post 来自 Ionic 的 Mike Hartington

    【讨论】:

    • 工作得很好:-D
    【解决方案2】:

    是的,离子弹出内容中可以有换行符。

    标签替换 \n 即可。离子框架在执行该 javascript 后输出 HTML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-18
      • 1970-01-01
      • 2020-10-09
      • 1970-01-01
      • 1970-01-01
      • 2018-07-10
      • 2017-03-15
      • 1970-01-01
      相关资源
      最近更新 更多