zoukankan      html  css  js  c++  java
  • Ant Design Vue 中table表格解析 HTML

    Ant Design Vue 中table表格解析 HTML

    场景: 后台返回的数据中有HTML,让前台解析出来

    解决方案: 主要使用   scopedSlots  和  slot-scope 和 v-html 

    demo:

    <template>
        <div>
            <h3>解析HTML的p标签</h3>
            <a-table :columns="columns" :data-source="data"  :pagination="false" :rowKey="(record,index)=>{return index}">
                <a slot="name" slot-scope="text" v-html="text"> {{ text }}</a>
            </a-table>
        </div>
    </template>
    <script>
    
        /* 这是ant-design-vue */
        import Vue from 'vue'
        import Antd, { message,Select } from 'ant-design-vue'  //这是ant-design-vue
        import 'ant-design-vue/dist/antd.css'
        Vue.use(Antd);
        /* 这是ant-design-vue */
        const columns = [
            {
                title: '姓名',
                dataIndex: 'name',
                key: 'name',
                scopedSlots: { customRender: 'name' }, // scopedSlots 这个属性很关键
            },
        ];
    
        const data = [
            {
                key: '1',
                name: 'daFei_01 <p>我是p标签</p>',
            },
            {
                key: '2',
                name: 'daFei_02',
            },
        ];
    
        export default {
            data() {
                return {
                    data,
                    columns
                }
            },
        };
    </script>
    
    <style scoped>
    
    </style>
    View Code

  • 相关阅读:
    touch命令
    cd命令
    通配符
    速查命令
    一些技巧
    从零开始用 Flask 搭建一个网站(四)
    【老板来了你立刻知道!】人脸识别+手机推送
    React Native 一些事
    React-Native 工程添加推送功能 (iOS 篇)
    集成 jpush
  • 原文地址:https://www.cnblogs.com/dafei4/p/13331073.html
Copyright © 2011-2022 走看看