If I console.log(window.location)
我明白了:
Location {replace: function, assign: function, ancestorOrigins: DOMStringList, origin: "https://localhost:3000", hash: "#/account/content?hello=world"…}
ancestorOrigins: DOMStringList
assign: function () { [native code] }
hash: "#/account/content?hello=world"
host: "localhost:3000"
hostname: "localhost"
href: "https://localhost:3000/#/account/content?hello=world'"
origin: "https://localhost:3000"
pathname: "/"
port: "3000"
protocol: "https:"
reload: function reload() { [native code] }
replace: function () { [native code] }
search: ""
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
__proto__: Location
我预计search
to be ?hello=world
,但事实并非如此。
Why?
我使用的是 Chrome 35
Because ?hello=world
在您的情况下不被视为查询字符串。
它是的一部分anchor
(#
) 可以使用以下方法获得
window.location.hash
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)