美文网首页
JS 的 URL 编码与解码

JS 的 URL 编码与解码

作者: 千罹 | 来源:发表于2016-08-08 14:43 被阅读27次
  1. 将中文的url编码成utf8
encodeURIComponent('你好');
%E4%BD%A0%E5%A5%BD //输出这个
  1. 将utf8编码转换成汉字
decodeURIComponent('%E4%BD%A0%E5%A5%BD');
'你好'

decodeURIComponent()
decodeURIComponent()

应该是全局的方法

相关文章

网友评论

      本文标题:JS 的 URL 编码与解码

      本文链接:https://www.haomeiwen.com/subject/ukrrsttx.html