是否有咖啡脚本的分组运算符?我试图把这个:
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
进入咖啡脚本。到目前为止我有这个,但我没有得到正确的
window.onpopstate = ->
pl = /\+/g # Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g
decode = (s) ->
return decodeURIComponent(s.replace(pl, " "))
query = window.location.search.substring(1)
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
试图提醒,但得到urlParams is not defined
jQuery ->
alert(urlParams['hair'])
可能是因为()
函数末尾的我没有得到它?