警报信息上的新行

时间:2018-04-19 04:45:31

标签: ionic2 ionic3

是否有使用Ionic 3中的警报显示新行?

我应该用'

替换'\ 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...

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

2 个答案:

答案 0 :(得分:4)

AlertController可以解析HTML标记。因此,您可以在此处使用Order of execution When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution. If you truly want parallel execution, you can invoke executeOnExecutor(java.util.concurrent.Executor, Object[]) with THREAD_POOL_EXECUTOR. 标记。

<br/>

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

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

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

答案 1 :(得分:0)

是的,离线弹出内容中可能有换行符。

将\ n替换为&lt; br&gt; 标签,它的工作原理。离子框架在执行该javascript后输出HTML。