Javascript 反应本机获取url
我有这个链接http://localhost:5000/index.html?cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp如何仅获取此部件cmluaWRhZDUxMbWFpbC5jb218YXlpYnFpJavascript 反应本机获取url,javascript,reactjs,react-native,Javascript,Reactjs,React Native,我有这个链接http://localhost:5000/index.html?cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp如何仅获取此部件cmluaWRhZDUxMbWFpbC5jb218YXlpYnFp let location_url = window.location.pathname; let new_url = ''; console.log("location_url.charAt( 0 ): &q
let location_url = window.location.pathname;
let new_url = '';
console.log("location_url.charAt( 0 ): ",location_url.charAt( 0 ))
console.log("location_url.slice( 1 ): ",location_url.slice( 1 ))
if( location_url.charAt( 0 ) === '/' )
new_url = location_url.slice( 1 );
console.log(new_url)
您可以这样做:
// Get your url string
var fullURL = window.location.href;
// Build an URL from the string
var URL = new URL(fullURL);
// Extract the data you are looking for
var result = URL.searchParams.toString();
您可以这样做:
// Get your url string
var fullURL = window.location.href;
// Build an URL from the string
var URL = new URL(fullURL);
// Extract the data you are looking for
var result = URL.searchParams.toString();
这回答了你的问题吗?这回答了你的问题吗?