vue2 el-table中显示json数据

要这样:

 用到插件:vue-json-pretty

// 安装
npm install vue-json-pretty@1.7.1 --save

// 在使用页面引入
import VueJsonPretty from 'vue-json-pretty/lib/vue-json-pretty.js'

// 注册
components: { VueJsonPretty },

// 使用--我这边是封装的组件,具体按需求来,json格式的要使用JSON.parse转一下
<!-- 自定义tooltip -->
                <el-table-column v-if="item.type === 'tooltipDialog'" :align="item.align || 'center'"
                    :width="item.width || ''" :formatter="item.formatter || null" :fixed="item.fixed"
                    :label="item.label" :key="item.type + index" :prop="item.key">
                    <template slot-scope="scope">
                        <el-tooltip placement="top" effect="light">
                            <div slot="content" class="tooltip_content">
                                <vue-json-pretty :deep="1" selectableType="single" :showSelectController="false"
                                    :highlightMouseoverNode="true" path="res"
                                    :data="scope.row[item.key] && scope.row[item.key] != null ? JSON.parse(scope.row[item.key]) : '暂无数据'">
                                </vue-json-pretty>
                            </div>
                            <el-button class="see_tooltip">{{ item.tooltipBtn ? item.tooltipBtn : '查看' }}</el-button>
                        </el-tooltip>
                    </template>
                </el-table-column>


效果如下:可打开json数据 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值