js获取富文本中所有的图片地址

富文本内容

转换代码

getImgSrc(richtext) {
    let imgList = [];
    richtext.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/g, (match, capture) => {  //match表示img元素,capture表示img地址
          imgList.push(capture);
    });
    return imgList;
}

转换后

posted @ 2020-09-15 13:49  huihuihero  阅读(2539)  评论(0编辑  收藏  举报