[我正在尝试从URL中获取参数,但我无法确定它是否有效,因为在localhost:3000上的console.log(window.location.search)
给了我<empty string>
作为值。
我已经尝试过像这样嘲笑它,但是它没有返回与window.location.search
相同的东西>
const url = 'https://www.google.com/search?client=firefox-b-1-d&q=query+string const queryString = url.search console.log(queryString) // function search()
是否有一种方法可以在本地模拟window.location.search的行为,因此可以确保在部署应用程序之前可以获取所需的数据?
我正在尝试从URL中获取参数,但是我无法确定它是否有效,因为localhost:3000上的console.log(window.location.search)给我