💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
在URL或URI中,有一些字符是具有特殊含义的。如果我们想“转义”这些字符,就可以去调用函数encodeURI()或encodeURIComponent()。 前者会返回一个可用的URL,而后者则会认为我们所传递的仅仅是URL的一部分。 例如: ``` >>> var url = 'http://find35.com/index.php?s =/Home/Article/index/id/191.html'; undefined >>> encodeURI(url); http://find35.com/index.php?s%20=/Home/Article/index/id/191.html >>> encodeURIComponent(url); http%3A%2F%2Ffind35.com%2Findex.php%3Fs%20%3D%2FHome%2FArticle%2Findex%2Fid%2F191.html ``` encodeURI()对应的解码是decodeURI() encodeURIComponent()对应的解码是decodeURIComponent()