SoFunction
Updated on 2025-04-03

vue operation to get url parameters and get parameters to return array

This is the vue filter to get the url parameter, return the array

.$url=function(){
 var url = decodeURIComponent(); //Get the string after the "?" character in the url var theRequest = new Object();
 if (("?") != -1) {
  var str = (1);
  strs = ("&");
  for(var i = 0; i < ; i ++) {
   theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  }
 }
 return theRequest;
};

Supplementary knowledge:Use getUrlParam() method in vue to get the URL value

First create one, and then introduce it to the required page:

export function getUrlParam(name) {
 return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec() || [, ""])[1].replace(/\+/g, '%20')) || null
}

Quote

import { getUrlParam } from “…/components/GetUrlParam”;

use:

let id = getQueryString(“ryid”); // Parameter name 1let model = getUrlParam(“model”); // Parameter name 2( id )
( model )

The above article vue's operation of obtaining url parameters and get parameters to return to array is all the content I share with you. I hope you can give you a reference and I hope you can support me more.