The front end gets the parameters for url address splicing

 There is a function: develop a shared link in the enterprise WeChat and open it in WeChat. At this time, the parameters of the enterprise WeChat cannot be obtained in the WeChat browser, so the required parameters are spliced ​​into the shared link. The following code uses js to get the parameters for link splicing. .

let URL = window.location.href

function getUrlParams(url){

         var urlStr = url.split("?")[1] 

          var obj = {}

          var paramArray = urlStr.split('&')

          var len = paramArray.length

          for(var i=0;i<len;i++){

                let arr = paramArray[i].split('=')

                obj[arr[0]] = arr[1]

            }

            return obj

 }

 console.log(getUrlParams(URL).wxId)

Guess you like

Origin blog.csdn.net/qq_43532275/article/details/132716353