firemail
标题:
js C++ 字符串转换
[打印本页]
作者:
Qter
时间:
2022-11-11 09:20
标题:
js C++ 字符串转换
本帖最后由 Qter 于 2022-11-18 14:21 编辑
note.htmlBody.replace("\\", "\\\\").replace("\r", "\\r").replace("\n", "\\n").replace("\"", "\\\"").replace("`", "\`");
note.htmlBody.replace("\\", "\\\\").replace("\r", "\\r").replace("\n", "\\n").replace("\"", "\\\"").replace("`", "\`");
复制代码
最后用正则防止 \r 中的\ 被替换掉
ExecuteJavaScript 调用前端js函数传参问题对传入的叁数有两步验证,所以要进行相关字符的替换
1.字符串的有效性
2.json格式的有性
QString strPara = QString("window.resultNoteCallback('%1','%2',`%3`);").arg(orderIndexStr).arg(intferName).arg(resultMsg);
((WebEngineView *)m_cloudPage)->getWebEngineViewPri()→runJavaScript(strPara);
复制代码
欢迎光临 firemail (http://firemail.wang:8088/)
Powered by Discuz! X3