onigetoc / json-tree-view-vue3

JSON tree rendering Vue3 component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json-tree-view-vue3

npm version TypeScript npm bundle size License: MIT code style: prettier

A Vue3 component that displays JSON in a collapsible tree. Inspired by vue-json-component and vue-json-tree-view to work with Vue3 and TypeScript.

Example

<script setup lang="ts">
import { JsonTreeView } from "json-tree-view-vue3";

const json = `{"string":"text","number":123,"boolean":true,"array":["A","B","C"],"object":{"prop1":"value1","nestedObject":{"prop2":"value2"}}}`
</script>

<template>
  <JsonTreeView :data="json" :maxDepth="3" />
</template>

image

Props

Props Required Param Type Default value Description
data false String JSON string to display the tree
rootKey false String "/" Top root-level name
maxDepth false Number 1 The depth of the tree that will be open when rendered
colorScheme false String "light" "light" or "dark" can be used.

Events

  • selected(event: {key: string, value: unknown, path: string}]

About

JSON tree rendering Vue3 component


Languages

Language:Vue 81.9%Language:HTML 9.1%Language:TypeScript 5.8%Language:JavaScript 3.2%