encodeURIComponent() 对 URI 进行编码
var uri="https://www.test.com/test?name=test&car=car"; // https%3A%2F%2Fwww.test.com%2Ftest%3Fname%3Dtest%26car%3Dcar console.log(encodeURIComponent(uri))
decodeURIComponent() 对编码后的 URI 进行解码
var uri = "https%3A%2F%2Fwww.test.com%2Ftest%3Fname%3Dtest%26car%3Dcar" // https://www.test.com/test?name=test&car=car console.log(decodeURIComponent(uri))
本文作者为gengboxb,转载请注明。