警报消息上的新行 [英] New line on alert message

查看:23
本文介绍了警报消息上的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there anyway to display new lines using an Alert in Ionic 3?

我应该用什么替换' '?

What should I replace ' ' with?

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

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

Eventually, the message will display variable just before the new line, but it is not required at this stage.

推荐答案

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

AlertController can parse HTML tags. So you can use <br/> tag here.

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...

或者您可以查看我的演示并尝试带有项目符号或编号的东西.

Or you can check my demo and try something with bullets or numbering.

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>
      `,

来源:这个论坛帖子,作者是 Ionic 的 Mike Hartington

Source: this forum post by Mike Hartington of Ionic

这篇关于警报消息上的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆