如何解决Sweetalert2标题中未显示错误消息
我使用的是 angular 8。
在我的 ts 文件中
getCurrentQuestion(): void {
this.questionService.getQuestionByFilter(this.questionFilter).subscribe(data => {
this.currentQuestion = data.question;
},err => {
if (err.status === 416) {
console.log(err.error.description);
Swal.fire({
title: err.error.description,type: 'success',showCloseButton: false,showCancelButton: false,focusConfirm: true,confirmButtonText:
'<i class="fa fa-thumbs-up" style="color: white"></i> Great!',confirmButtonAriaLabel: 'Thumbs up,great!',confirmButtonColor: '#3085d6',}).then((result) => {
this.finishedExercise();
});
} else {
this.alertService.showError(err.error.description);
}
});
}
但如果我使用变量,则标题会显示在 Sweetalert2 中。
getCurrentQuestion(): void {
this.questionService.getQuestionByFilter(this.questionFilter).subscribe(data => {
this.currentQuestion = data.question;
},err => {
if (err.status === 416) {
console.log(err.error.description);
let message = err.error.description;
Swal.fire({
title: message,}).then((result) => {
this.finishedExercise();
});
} else {
this.alertService.showError(err.error.description);
}
});
}
为什么会这样?谁能解释一下?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。