이 두 가지 방법 중 URL 인코딩에 사용해야하는 방법은 무엇입니까?
encodeURI
인코딩되지 않는다는 것입니다 /
. encodeURIComponent("ac/dc")
=> ac%2Fdc
및 encodeURI("ac/dc")
=>ac/dc
"encodeURIComponent() and encodeURI() encode a URI by replacing URL reserved characters with their UTF-8 encoding....They differ because encodeURI does not encode queryString or hash values...URLs do not allow many special characters, like spaces or slashes. However these special characters are part of life, so URL encoding was invented."
소스
encodeURIComponent differs from encodeURI as follows
.