美文网首页
小程序提取富文本中的文字并指定长度

小程序提取富文本中的文字并指定长度

作者: 张大娃创业笔记 | 来源:发表于2019-04-05 22:29 被阅读0次
    getSimpleText(html){
        var re1 = new RegExp("<.+?>", "g");//匹配html标签的正则表达式,"g"是搜索匹配多个符合的内容
        var msg = html.replace(re1, '');//执行替换成空字符
        return msg;
      }
    //调用
    that.getSimpleText(item.des_ppcontent).substring(0,20)
    

    相关文章

      网友评论

          本文标题:小程序提取富文本中的文字并指定长度

          本文链接:https://www.haomeiwen.com/subject/imxliqtx.html