本文介绍了警报信息上的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无论如何使用Ionic 3中的警报显示新行吗?
Is there anyway to display new lines using an Alert in Ionic 3?
我应该用'
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...
最后,消息将在新行之前显示变量,但它在这个阶段不需要。
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
这篇关于警报信息上的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!