URL包含特殊字符 前端转码处理

202 阅读1分钟

encodeURIComponent(str) 方法

let url='$2a$10$Wwy0/kOanqWCB36HL2ctie1MSIj6fvtFCbvhTuvq2GxOki3C7M1ZK';
let b=encodeURIComponent(url);
let c= decodeURIComponent(b);
console.log(b);
console.log(c);

打印转义和解码结果:

1689734444157.png