2022-04-12 发送代码片段不被解析

js   const escapeHtml = (html = '') => {

    let temp = document.createElement('div')

    temp.textContent !== undefined ? (temp.textContent = html) : (temp.innerText = html)

    let output = temp.innerHTML

    temp = null

    return urlConversion(output)

}

const urlConversion = (val = '') => {

    let reg= /[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/g;

    let reStr = val.replace(reg, function (match) {

        var href = match;

        if (match.indexOf("http") == -1) {

          href = "http://" + match; //加粗样式

        }

        return '' + match + "";

    })

    return reStr

}

export {

    escapeHtml

}



 if (this.detailList && this.detailList.topiccontent) {

                        this.detailList.topiccontent = escapeHtml(this.detailList.topiccontent)

                    }

你可能感兴趣的:(2022-04-12 发送代码片段不被解析)