1、如果只是編碼字符串,不和URL有半毛錢關系,那么用escape。 2、如果你需要編碼整個URL,然后需要使用這個URL,那么用encodeURI。 比如 encodeURI("http://www.dbjr.com.cn/season-huang/some other thing"); 編碼后會變?yōu)?"http://www.dbjr.com.cn/season-huang/some%20other%20thing"; 其中,空格被編碼成了%20。
www.dbjr.com.cn/article/1409...htm 2025-5-21