前端向后端穿的参数包含&,如何解决?
使用 encodeURIComponent() 对 URI 进行编码:
对URL不进行编码的情况下: window.location.href= '{% url 'b' %}?num=aaa&aa' num 的值就会为 aaa,因为&是拼接参数 对URL进行编码: var url = encodeURIComponent('{% url 'b' %}?a=aaa&aa') window.location.href= url 这样 num 的值就会为 aaa&aa。

浙公网安备 33010602011771号