We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function parseQueryString(url) { url = url == null ? window.location.href : url var search = url.substring(url.lastIndexOf('?') + 1) if (!search) { return {} } return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') } 以上这个方法为什么不直接写出url = url || window.location.href? 这样做是有什么好处吗?
The text was updated successfully, but these errors were encountered:
两个作用一样
Sorry, something went wrong.
url = url || window.location.href,也没有问题, url == null ? window.location.href : url,这样是为了只判断url为undefined或null的情况,排除一些其他类型的情况。
url = url || window.location.href
url == null ? window.location.href : url
url
undefined
null
我想太多了。。。
No branches or pull requests
function parseQueryString(url) {
url = url == null ? window.location.href : url
var search = url.substring(url.lastIndexOf('?') + 1)
if (!search) {
return {}
}
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
}
以上这个方法为什么不直接写出url = url || window.location.href? 这样做是有什么好处吗?
The text was updated successfully, but these errors were encountered: