var div1 = '';
imgMatch(str){
// var reg = /\w(\.jpeg | \.png | \.jpg)/i; // \w = [A-Za-z_0-9];
var reg = /(\.jpeg | \.png | \.jpg)/i; //图片名为汉字的也可以匹配到
reg.test(str); //返回true ,false
}
//正则匹配换行符
changeString(strr){
let str = strr.replace(/[\n]+/g, '</br>');
let label = str.split('</br>');
return label;
}
response.data.data.map(item){
var labelArr = this.changeString(item);
labelArr.forEach((str) =>{
if(str !== ''){
div1+=`<p style="line-height:32px;">${str}</p>`;
let flag = this.imgMatch(str);
if(flag){
let dom =`<div> <img :src=" 'data:image/png;base64,' + ${item.value} " alt=" "/></div>`;
div1 += dom;
}
}
}
document.getElementById('editDetail').innerHTML = div1;
}
网友评论