URLSearchParams为第一个查询字符串返回null

问题描述 投票:1回答:1

为什么timeperiod为null

const url = 'http://example.com?timeperiod=lasttwentyeightdays&pagesize=20'
const args =  new URLSearchParams(url);
alert('timeperiod='+args.get('timeperiod') + ' and pagesize='+ args.get('pagesize'));

但是在下面的代码中它可以工作

  const url = 'http://example.com?x=c&timeperiod=lasttwentyeightdays&pagesize=20'
  const args =  new URLSearchParams(url);
  alert('timeperiod='+args.get('timeperiod') + ' and pagesize='+ args.get('pagesize'));
javascript html5
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.