问题描述
所以我有这个代码(一个函数),在谷歌Chrome / Fire Fox,但不是在IE。
我有一个名为ReadCookie的函数,它基本上只是将cookie存储到一个名为cookiearray的数组中
function ReadCookie(){
var allcookies = document.cookie; //变量名为allcookies存储所有的cookie。
cookiearray = allcookies.split(';')。map(c => c.split('=')[1]); // cookiearray是一个将所有值作为字符串的数组。
}
IE说第四行不正确 cookiearray = allcookies.split(';')。map(c => c.split('=')[1]);
但我不知道为什么。 >
谢谢!
我相信这是一个ECMA脚本6 与您使用地图的方式。
所以你可以这样写:
cookiearray = allcookies.split ';')。map(function(c){
return c.split('=')[1];
}); // cookiearray是一个将所有值作为字符串的数组。
So I have this code (a function) that works in Google Chrome/Fire Fox but not in IE. If I comment this certain line, everything runs fine, except that line is crucial.
I have this function called ReadCookie, which basically just stores the cookies into an array called cookiearray.
function ReadCookie() {
var allcookies = document.cookie; //variable called "allcookies" stores all the cookies.
cookiearray = allcookies.split(';').map(c => c.split('=')[1]); //cookiearray is an array that has all the values as strings.
}
IE said that the 4th line is incorrect cookiearray = allcookies.split(';').map(c => c.split('=')[1]);
but I don't know why.
Thanks!
I believe it's an ECMA script 6 thing with the way you're using the map.
So you can write it like this instead:
cookiearray = allcookies.split(';').map(function (c) {
return c.split('=')[1];
}); //cookiearray is an array that has all the values as strings.
这篇关于我在IE中遇到语法错误,但Chrome中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!