<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
function formatLaber (text) {
debugger
if (!text) {//替换富文本 标签
return;
}
let newval = text.replace(/<img/g, '<img class="richTextImg"');;
return newval;
}
let con = `<p><img src="https://oss.jinyicheng.51daoteng.com/mallFile/20230905-64f6f6a5b0d27.jpg" /></p>`;
let newval = formatLaber(con);
console.log(newval)
</script>
</head>
<body>
</body>
</html>
//输入的文本替换< > 防止xss攻击
function filterInput(input) {
return input.replace(/</g, '<').replace(/>/g, '>');
}