小程序富文本针对图片表格的处理

<rich-text :nodes="richTxt"></rich-text>

created里面的处理:

created() {
            const regex = new RegExp('<img', 'gi');
            const regexTable = new RegExp('<table', 'gi');
            this.richTxt = this.content.richTxt.replace(regex, `<img style="max- 100%;"`);
            this.richTxt = this.richTxt.replace(regexTable, `<table style=" 100%;border:1px solid grey" border="0" cellspacing="1" cellpadding="0"`);
        }

RegExp 对象表示正则表达式,第二个参数:g是执行全局匹配(查找所有匹配而非在找到第一个匹配后停止)、i是执行对大小写不敏感的匹配、m是执行多行匹配

搞了半天,我还以为我会呢
原文地址:https://www.cnblogs.com/dongdong1996/p/14368055.html