IE中未定义Javascript函数
这适用于Chrome和FF,但不适用于IE: 我称我的JS在身体中部:IE中未定义Javascript函数,javascript,internet-explorer,Javascript,Internet Explorer,这适用于Chrome和FF,但不适用于IE: 我称我的JS在身体中部: <li><a href="#" onclick="destroy(80)" >Delete</a></li> IE(11)给出:“销毁”未定义 我一直在开发Chrome,这是我第一次不得不支持IE 我在做傻事吗 更新 我已经为函数添加了完整的代码。这是因为sweet警报(swal)正在使用ES6吗 在添加注释后添加了更多详细信息。这是因为我使用了ES6中的箭头功能 我将函数
<li><a href="#" onclick="destroy(80)" >Delete</a></li>
IE(11)给出:“销毁”未定义
我一直在开发Chrome,这是我第一次不得不支持IE
我在做傻事吗
更新
我已经为函数添加了完整的代码。这是因为sweet警报(swal)正在使用ES6吗
在添加注释后添加了更多详细信息。这是因为我使用了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);
}
});
}
很难帮助调试这个。。。。要么在加载文件之前调用它,要么出现了阻止加载的错误,要么出现了100多个其他问题。是的,这就是我请求帮助的原因。接下来该怎么办?IE11不支持箭头函数。控制台几乎肯定会给你一个语法错误,你至少有一个问题。如果没有箭头函数,我怎么能重写这个函数呢?不需要魔法,只需在(willDelete)
前面加上=>
,然后删除
。
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);
}
});
}
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);
}
});
}