识别小程序码得路径和参数?
例如:有多个小程序码 码1:path = 123 码2: path=456
怎么样才能快速识别他们得参数和路径呢?
例如:有多个小程序码 码1:path = 123 码2: path=456
怎么样才能快速识别他们得参数和路径呢?
getQueryString 可封装到 util下。下次直接调用 util.getQueryString[‘参数名’]
//页面初始化加载
if (!options.scene) { //判断不是从小程序码进来的 this.setData({ partJobId: options.partJobId || '', }) } else { var getQueryString = {} var strs = decodeURIComponent(options.scene).split('&') //以&分割 //取得全部并赋值 for (var i = 0; i < strs.length; i++) { getQueryString[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]) } this.setData({ partJobId: getQueryString['partJobId'] || '' }) } }, |