zoukankan      html  css  js  c++  java
  • vue+elementui项目去除html标签

    1、html代码

         <div slot="ti_content" style=" 100%;height: 250px;overflow-y: auto;">
            <span v-html="highlight(addFromData.ti_content)"></span>
          </div>
    

      

           <el-table-column slot="ti_content" label="文章内容" align="left" width="300px">
              <template slot-scope="scope">
                <div class="contentClass">{{scope.row.ti_content.replace(/<[^>]+>/g, '')}}</div>
              </template>
            </el-table-column>
    

      如果想使用方法的话,可以

            <el-table-column slot="ti_content" label="文章内容" align="left" width="300px">
              <template slot-scope="scope">
                <div class="contentClass">{{ highlight(scope.row.ti_content) }}</div>
              </template>
            </el-table-column>
    
       方法 methods:[ 适合table之类的不用显示文字样式 ]
       highlight (item) {
          return item.replace(/<[^>]+>/g, '')// 去掉所有的html标记
        },
    

      

    2、methods:

    // 该方法适用于 v-html 的显示 如下图
    highlight (item) { //const removehtml = (str = '') => str.replace(/<[/!][^<>]>/gi, '') //return removehtml(item)
    },

      

  • 相关阅读:
    Java基础知识
    jQuery的表单操作
    SSM——查询_分页
    jQuery实现查看删除
    SSM之Maven工程的搭建
    Mybatis使用@Param
    Mybatis简单的CURD
    Mybatis使用接口开发
    初入Mybatis
    SQL语句
  • 原文地址:https://www.cnblogs.com/sylys/p/13672090.html
Copyright © 2011-2022 走看看