1.0.1 • Published 3 years ago

json-pretty-patch v1.0.1

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

Build Status npm package GitHub license Sizes NPM downloads Issues

npm.io

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 / EdgeFirefoxChromeSafariElectron
IE11, Edgelast 10 versionslast 10 versionslast 10 versionslast 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.
AttributeLevelDescriptionTypeDefault
datanormalJSON dataJSON object-
deepnormalData depth, data larger than this depth will not be expandednumberInfinity
showLengthnormalWhether to show the length when closedbooleanfalse
showLinenormalWhether to show the linebooleantrue
showDoubleQuotesnormalWhether to show doublequotes on keybooleantrue
virtualnormalWhether to use virtual scrolling, usually used for big databooleanfalse
itemHeightnormalThe height of each item when using virtual scrollingnumberauto
v-modelhigherDefines value when the tree can be selectedstring, array-
pathhigherRoot data pathstringroot
pathSelectablehigherDefines whether a data path supports selectionfunction(path, content)-
selectableTypehigherDefines the selected type, this feature is not supported by defaultmultiple, single-
showSelectControllerhigherWhether to show the select controller at leftbooleanfalse
selectOnClickNodehigherWhether to change selected value when click nodebooleantrue
highlightSelectedNodehigherHighlight current node when selectedbooleantrue
collapsedOnClickBracketshigherCollapsed controlbooleantrue
customValueFormatterhigherA function that can return different html or strings to display for values in the data.function(data, key, path, defaultFormatResult)-

Events

Event NameDescriptionCallback Parameters
clicktriggered when a data item is clicked(path, data)
changetriggered when the selected value changed (only the selectableType not null)(newVal, oldVal)

Major Contributors

npm.io npm.io