将地址栏参数截取成键值对

    getString (str) {
      let str1 = str.split('&')
      let strArr = []
      str1.forEach(element => {
        let str2 = element.split('=')
        let a = {
          [str2[0]]: str2[1]
        }
        strArr.push(a)
      });
      console.log(str1)
    },

 

posted @ 2018-11-12 21:52  Candy-Yao  阅读(385)  评论(0编辑  收藏  举报