function encodeToBase64(str) { return window.btoa(unescape(encodeURIComponent(str))); // 用于处理特殊字符 } var str = {"method":"GET","timestamp":1714959030876,"url":"https://interactive.hn0746.com/activities/appColumnConfig/getColumnsOfAvailableModel?appInfoId\u003d596\u0026appModelId\u003d298"}; var base64 = encodeToBase64(JSON.stringify(str)); console.log(base64); // 输出类似 "SGVsbG8sIFdvcmxkIQ=="