这适用于Chrome和FF但不适用于IE: 我把我的JS称为身体中间:
<li><a href="#" onclick="destroy(80)" >Delete</a></li>
我像这样加载我的JS文件(关闭正文标记之前):
<script src="https://thing.test/js/things-common.js"></script>
它有这样的功能:
function destroy(id)
swal({
text: "Do you really want to delete this thing?",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
//AJAX the delete
AxiosDestroyThing(id);
}
});
}
IE(11)给出:'destroy' is undefined
我一直在开发Chrome,这是我第一次不得不支持IE。
我在做些傻事吗?
更新
我添加了该功能的完整代码。这是因为甜蜜警报(swal)正在使用ES6吗?
添加评论后添加了更多详细信息。
答案 0 :(得分:2)
这是因为我使用的是ES6的箭头功能。
我将功能更改为:
function destroy(id) {
swal({
text: "Do you really want to delete this thing?",
icon: "warning",
buttons: true,
dangerMode: true
}).then(function (willDelete) {
if (willDelete) {
//AJAX the delete
AxiosDestroyThing(id);
}
});
}