this.acc = this.acc.replace(/&(amp|gt|lt|quot|#39|nbsp);/g, (a) => {
return {
"<": "<",
"&": "&",
""": '"',
">": ">",
"'": "'",
" ": " ",
}[a];
});
反转义
str.replace(/(["'<>]|&(?:(amp|lt|gt|#39|nbsp|quot|#\d+);)?)/g, (a, b, c) =>
c
? a
: {
'<': '<',
'&': '&',
'"': '"',
'>': '>',
"'": '''
}[a]
)
vue v-html渲染转义
最新推荐文章于 2023-11-30 16:27:36 发布