将小程序scene中的字符串转为对象

 

  sceneToObject:function(scene){
    scene = decodeURIComponent(scene);
    let ret = {}
    let regParam = /([^&=]+)=([\w\W]*?)(&|$|#)/g
    let strParam = scene;
    let result
    while ((result = regParam.exec(strParam)) != null) {
      ret[result[1]] = result[2]
    }
    return ret;
  }

 

posted @ 2021-12-09 17:11  Mr.木易  阅读(355)  评论(0编辑  收藏  举报