ReadCookie_sns = function(){ ReadCookie("myname"); }出錯(cuò),提示:Unexpected token u in JSON at position 0改為:ReadCookie_sns = function(){ return ReadCookie("myname"); }好了。 加了return, 就好了。請(qǐng)問(wèn)為什么?-----------------下面是ReadCookie方法。ReadCookie = function(cookieName) { var theCookie = "" + document.cookie; var ind = theCookie.indexOf(cookieName); if (ind == -1 || cookieName == "") return ""; var ind1 = theCookie.indexOf(';', ind); if (ind1 == -1) ind1 = theCookie.length; /*讀取Cookie值*/ return unescape(theCookie.substring(ind + cookieName.length + 1, ind1)); }
JS方法里面沒(méi)有加return,就出錯(cuò)了?
胡說(shuō)叔叔
2018-09-12 13:19:43