首页 > 其他分享 >获取?后参数

获取?后参数

时间:2022-08-26 10:12:00浏览次数:53  
标签:obj indexOf 获取 参数 split str paramName let

paramName = '/indicator?id=123'
            getParam(paramName) {
                let obj = {}
                if(!isEmpty(paramName)){
                    if(paramName.indexOf('?') != -1){
                        let str = ''
                        str = paramName.split('?')[1]
                        if(str.indexOf('&') != -1){
                            str = str.split('&')
                        }else{
                            str = [str]
                        }
                        str.map(m => {
                            if(m.indexOf('=') != -1){
                                obj[`${m.split('=')[0]}`] = m.split('=')[1]
                            }
                        })

                    }
                }
                return obj
            },

 

标签:obj,indexOf,获取,参数,split,str,paramName,let
From: https://www.cnblogs.com/myqinyh/p/16626629.html

相关文章