使用危险设置的innerHTML在React中渲染unicodes

问题描述 投票:0回答:1
javascript reactjs unicode
1个回答
0
投票

decodeURIComponent”函数解码 Unicode 转义序列

const data = '\\n <p>We\\u00e2\\u0080\\u0099re looking for a Customer Success Manager, Scale to join our team of five \\u00e2\\u0080\\u009cmisfits that fit\\u00e2\\u0080\\u009d.&nbsp;</p>';

const decodedNewString = decodeURIComponent(JSON.parse(`"${data}"`));
console.log(decodedNewString)

/*
I got this result I hope this code help you.
 <p>Weâre looking for a Customer Success Manager, Scale to join our team of five âmisfits that fitâ.&nbsp;</p>
*/
© www.soinside.com 2019 - 2024. All rights reserved.