一、encodeURI encodeURI函数主要用于编码整个URL。当URL中包含非ASCII字符、空格或其他在URL中有特殊意义的字符时,可以使用encodeURI进行编码。下面是一个使用encodeURI的例子: // 假设有一个URL var url = "https://www.example.com/index.html?name=John Doe"; // 使用encodeURI进行编码 var encodedUrl = encodeURI(url); console.log(encodedUrl