我正在使用 SweetAlert2 examples page 的确切代码:
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.value) {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
})
在 Firefox 和 Chrome 上工作正常,但 Internet Explorer 显示 SCRIPT1002: Syntax Error
并且不运行脚本...IE 将此部分标记为语法错误:
}).then((result) => {
感谢您的帮助
最佳答案
(result) => {}
是一个箭头函数,IE 完全不支持它。要解决此问题,您必须使用传统的匿名函数:
swal({
// options...
}).then(function(result) {
if (result.value) {
swal('Deleted!', 'Your file has been deleted.', 'success');
}
});
关于javascript - Internet Explorer 11 上的 SweetAlert2 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49896811/