encodeURI方法不会对下列字符编码 ASCII字母、数字、~!@#$&*()=:/,;?+' encodeURIComponent方法不会对下列字符编码 ASCII字母、数字、~!*()' 因此encodeURIComponent比encodeURI编码的范围更大。 实际例子来讲,encodeURIComponent会把 http:// 编码成 http%3A%2F%2F 而encodeURI却不会。 若是你须要编码整个 URL,而后须要使用这个URL,那么用encodeURI。 当你须要编码 URL中的参数的时候,那么encodeURIComponent是最好方法