GithubHelp home page GithubHelp logo

gwd-1 / vue-json-pretty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from leezng/vue-json-pretty

0.0 0.0 0.0 2.83 MB

A JSON tree view component that is easy to use and also supports data selection.

Home Page: https://leezng.github.io/vue-json-pretty

License: MIT License

JavaScript 70.01% HTML 0.17% Vue 9.75% Less 3.36% TypeScript 16.72%

vue-json-pretty's Introduction

A Vue component for rendering JSON data as a tree structure.

Now it supports Vue3 at least. If you still use Vue2, see 1.x.

Build Status npm package GitHub license Sizes NPM downloads Issues

English | 简体中文

Features

  • As a JSON Formatter.
  • Get item data from JSON.
  • Written in TypeScript with predictable static types.
  • Support big data.

Environment Support

  • Modern browsers, Electron and Internet Explorer 11 (with polyfills)
  • Server-side Rendering
IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edge last 10 versions last 10 versions last 10 versions last 2 versions

Using NPM or Yarn

$ npm install vue-json-pretty --save
$ yarn add vue-json-pretty

Use Vue3

$ npm install vue-json-pretty@next --save

Usage

The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.

<template>
  <div>
    <vue-json-pretty :path="'res'" :data="{ key: 'value' }" @click="handleClick"> </vue-json-pretty>
  </div>
</template>

<script>
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';

export default {
  components: {
    VueJsonPretty,
  },
};
</script>

Use Nuxt.js

  1. In plugins/vue-json-pretty.js
import Vue from 'vue'
import VueJsonPretty from 'vue-json-pretty'

Vue.component("vue-json-pretty", VueJsonPretty)
  1. In nuxt.config.js
css: [
  'vue-json-pretty/lib/styles.css'
],
plugins: [
  '@/plugins/vue-json-pretty'
],

Props

  • If you are using only the normal features (JSON pretty), just focus on the base properties.
  • If you are using higher features (Get data), you can use base and higher attributes.
Attribute Level Description Type Default
data normal JSON data JSON object -
deep normal Data depth, data larger than this depth will not be expanded number Infinity
deepCollapseChildren normal Whether children collapsed by deep prop should also be collapsed boolean false
showLength normal Whether to show the length when closed boolean false
showLine normal Whether to show the line boolean true
showDoubleQuotes normal Whether to show doublequotes on key boolean true
virtual normal Whether to use virtual scrolling, usually used for big data boolean false
itemHeight normal The height of each item when using virtual scrolling number auto
v-model higher Defines value when the tree can be selected string, array -
path higher Root data path string root
pathSelectable higher Defines whether a data path supports selection function(path, content) -
selectableType higher Defines the selected type, this feature is not supported by default multiple, single -
showSelectController higher Whether to show the select controller at left boolean false
selectOnClickNode higher Whether to change selected value when click node boolean true
highlightSelectedNode higher Highlight current node when selected boolean true
collapsedOnClickBrackets higher Collapsed control boolean true
customValueFormatter higher A function that can return different html or strings to display for values in the data. function(data, key, path, defaultFormatResult) -

Events

Event Name Description Callback Parameters
click triggered when a data item is clicked (path, data)
change triggered when the selected value changed (only the selectableType not null) (newVal, oldVal)

Major Contributors

vue-json-pretty's People

Contributors

leezng avatar dependabot[bot] avatar rchl avatar blackmad avatar fredrivett avatar lukefinch avatar luhis avatar henrikekblad avatar hsiaosiyuan0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.