使用 encodeURIComponent / decodeURIComponent,适用于查询参数与路径段(非整段 URL 的通用编码)。
encodeURIComponent
decodeURIComponent
若解码报错,请确认字符串为合法的 encodeURIComponent 输出(如 % 后接两位十六进制)。