export function unescape(html) { return html .replace(html ? /&(?!#?\w+;)/g : /&/g, '') .replace(/</g, "<") .replace(/>/g, ">") .replace(/"/g, "\"") .replace(/'/g, "\'") .replace(/nbsp;/g,"\u00a0") .replace(/&/g,"") } /** * 反转义html * @param html * @returns {*} */ export function unescapeHtml(html) { if(!html) return html; return html .replace(html ? /&(?!#?\w+;)/g : /&/g, '') .replace(/</g, "<") .replace(/>/g, ">") .replace(/"/g, "\"") .replace(/'/g, "\'") .replace(/nbsp;/g,"\u00a0") .replace(/&/g,"") } /** * 转义html * @param html * @returns {*} */ export function escapeHtml(html) { if(!html) return html; return html .replace(/&/g, '&') .replace(//g, '>') .replace(/\u00a0/g,"nbsp;") }