vue json数据可视化展示

使用vue-json-viewer插件
官网地址:https://www.npmjs.com/package/vue-json-viewer

  1. 安装vue-json-viewer插件
    npm install vue-json-viewer --save

  2. script里面导入包,定义jsonData,为它赋值,或是接收后端接口数据

    import JsonViewer from 'vue-json-viewer'
    import Vue from 'vue'
    Vue.use(JsonViewer)
    
    data() {
    return {
      jsonData: {
        id: '5968fcad629fa84ab65a5247',
        firstname: 'Ada',
        lastname: 'Lovelace',
        awards: null,
        known: [
          'mathematics',
          'computing'
        ],
        position: {
          lat: 44.563836,
          lng: 6.495139
        },
        description: `Augusta Ada King, Countess of Lovelace (née Byron; 10 December 1815 – 27 November 1852) was an English mathematician and writer,
            chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer,
            the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation,
            and published the first algorithm intended to be carried out by such a machine.
            As a result, she is sometimes regarded as the first to recognise the full potential of a "computing machine" and the first computer programmer.`,
        bornAt: '1815-12-10T00:00:00.000Z',
        diedAt: '1852-11-27T00:00:00.000Z'
      }
     }
    }
    
  3. 使用

    <json-viewer :value="jsonData" copyable boxed></json-viewer>
    
  4. 结果
    在这里插入图片描述

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值