[Vuejs]-How to get params id get in external js file

0๐Ÿ‘

I think you could use URLSearchParams (read more about it here) and URL (read more here)

const url = new URL(window.location.href);
const searchParams = new URLSearchParams(url.searchParams);
console.log(searchParams.has('id'));
console.log(searchParams.get('id'));

Leave a comment