是否可以在Ionic2吐司中使用换行符?

Ank*_*ari 8 ionic-framework ionic2

我试过了\n<br />,但遗憾的是没有工作!

这可能吗 ?

//Displaying toast to welcome user!
let user = this.currentUser();
//console.log(user);
let toast = Toast.create({
  message: 'Hi ' + user.email + '! <br/> Welcome to My App',
  duration: 5000,
  position: 'bottom'
});

toast.onDismiss(() => {
  console.log('Dismissed toast');
});

this.nav.present(toast);
Run Code Online (Sandbox Code Playgroud)

Ben*_*uer 16

实际上它是可能的.您可以执行以下操作:

.toast-message {
  white-space: pre;
}
Run Code Online (Sandbox Code Playgroud)

\n换行.

注意:看看home.tsstyle.css.

工作plunkr


Rez*_*eza 9

尽管@iWork解决方案适用于许多情况,但如果您close的吐司中有按钮,它将被推出屏幕.

所以你可以改用这些样式表:

.toast-message {
  white-space: pre-line;
}
Run Code Online (Sandbox Code Playgroud)

ps你需要\n在你的字符串中使用换行符