1.0.2 • Published 3 years ago

vue-json-tree-viewer v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
3 years ago

vue-json-tree-viewer

json tree viewer component , Customized color matching can be realized.

npm.io

Installation

Install the plugin with npm:

npm install -S vue-json-tree-viewer

Then

import JsonTreeViewer from "vue-json-tree-viewer"
Vue.use(JsonTreeViewer)

Usage

Use in your Vue component.

<div id="app">
  <JsonTreeViewer :value="jsonData" :options="options" />
</div>

Props

value

JSON object data to be displayed

options

Configuration related parameters

See at:

{
  defaultOpen: true, // default extend
  rootKeyName: 'root', // root key name
  sortable: false, // sortable for key
  defaultOpenDepth: 1, // default extend max depth
  styles: { // Text color
    key: { // key text color
      string: '#555',
      number: '#881391'
    },
    value: {// value text color
      string: '#c41a16',
      number: ' #1c00cf',
      boolean: '#0d22aa',
      null: '#e08331',
      undefined: '#e08331',
      function: '#067bca'
    }
  },
  parseLink: true, // Parsing text link
  keyNameQuote: false, // The key name quote  value: false / single / double
  valueNameQuote: 'double', //  single / double
  hints: { // Prompt when folding word
    array: ['item', 'items'],
    object: ['property', 'propertys']
  }
}

Options Detail:

attributerequireddefaulttypeexplain
defaultOpenfalsetrueBooleanExpand by default
rootKeyNamefalserootStringThe JSON tree root name
editablefalsefalseBooleanWhether the json tree can be edited
stylesfalse{}ObjectSome styles...
parseLinkfalsetrueBooleanWhether to parse text links
hintsfalse{}Objectplaceholder hints
defaultOpenDepthfalse1Numbermax default open depth
keyNameQuotefalsedoubleBoolean / StringThe key name quote ,value: false / single / double
valueNameQuotefalsedoubleStringThe value name quote , value:  single / double

styles:

custom your theme colors ( key / value)

  styles: { // Text color
    key: { // key text color
      string: '#555',
      number: '#881391'
    },
    value: {// value text color
      string: '#c41a16',
      number: ' #1c00cf',
      boolean: '#0d22aa',
      null: '#e08331',
      undefined: '#e08331',
      function: '#067bca'
    }
  }

hints:

set placeholder at collapse

hints: { // Prompt when folding word
    array: ['item', 'items'],
    object: ['property', 'propertys']
  }

:white_check_mark:collapse json tree

:white_check_mark:parse text links

:white_check_mark: custom styles

:x:editable json tree data(feature)

Event

update

:x: Triggered when json tree data is updated(feature)