var str = '中'; var code = encodeURI(str); console.log(code); // => %E4%B8%AD 转载于:https://www.cnblogs.com/alvin553819/p/7127318.html