如何编写此文件并使其在IE中运行?
var tEvents = eventsJSON.response.Events.filter(function (val, index, array) {
return val.participating_region.includes(varRegion);
});
totalEvents = tEvents.length;
我知道问题是.includes(),只是不知道怎么用.indexOf()
写这个完整代码:
var varRegion = $('body').data('region');
var eventsJSON = null;
var totalEvents;
var virtualEvents;
$.ajax({
'url': '/services/getAllEvents',
'dataType': 'json',
'success': function (data) {
eventsJSON = data;
parseJSONevents();
}
});
function parseJSONevents() {
var tEvents = eventsJSON.response.Events.filter(function (val, index, array) {
return val.participating_region.includes(varRegion);
});
totalEvents = tEvents.length;
$('.in-person-events').text(totalEvents);
return eventsJSON;
};
答案 0 :(得分:1)
return val.participating_region.indexOf(varRegion) > -1;
虽然在没有看到所有相关代码和JSON响应结构的情况下很难分辨。