JS模拟php的urlencode()

const urlCodeStr = encodeURIComponent(string).replace(/%20/gi, '').replace(/(!)|(')|(\()|(\))|(\~)/gi, item => {
    return '%' + item.charCodeAt(0).toString(16).toLocaleUpperCase();
  });

你可能感兴趣的:(JS模拟php的urlencode())