1
- # vue-json-pretty
1
+ <p align =" center " >
2
+ <a href =" https://github.com/leezng/vue-json-pretty " >
3
+ <img width="200" src="./static/logo.svg">
4
+ </a >
5
+ </p >
6
+
7
+ <h1 align =" center " >
8
+ <a href =" https://github.com/leezng/vue-json-pretty " target =" _blank " >Vue Json Pretty</a >
9
+ </h1 >
10
+
11
+ <div align =" center " >
12
+
13
+ <p >A Vue component for rendering JSON data as a tree structure.</p >
14
+ <p >Use Vue2, see <a href =" https://github.com/leezng/vue-json-pretty/tree/1.x " >1.x</a >.</p >
15
+ <p >Use Vue3, see <a href =" https://github.com/leezng/vue-json-pretty/tree/master " >master</a >.</p >
2
16
3
17
[ ![ Build Status] ( https://travis-ci.org/leezng/vue-json-pretty.svg?branch=master )] ( https://travis-ci.org/leezng/vue-json-pretty )
4
18
[ ![ npm package] ( https://img.shields.io/npm/v/vue-json-pretty.svg )] ( https://www.npmjs.org/package/vue-json-pretty )
5
19
[ ![ GitHub license] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( https://github.com/leezng/vue-json-pretty/blob/master/LICENSE )
20
+ [ ![ Sizes] ( https://img.shields.io/bundlephobia/min/vue-json-pretty )] ( https://bundlephobia.com/result?p=vue-json-pretty )
21
+ [ ![ NPM downloads] ( http://img.shields.io/npm/dm/vue-json-pretty.svg?style=flat-square )] ( https://www.npmtrends.com/vue-json-pretty )
22
+ [ ![ Issues] ( https://img.shields.io/github/issues-raw/leezng/vue-json-pretty )] ( https://github.com/leezng/vue-json-pretty/issues )
23
+
24
+ </div >
25
+
26
+ [ ![ ] ( ./static/screenshot.png )] ( https://github.com/leezng/vue-json-pretty )
27
+
28
+ English | [ 简体中文] ( ./README.zh_CN.md )
6
29
7
- A vue 2.x component for rendering JSON data as a tree structure.
30
+ ## Features
8
31
9
- - As a JSON Formatter
10
- - Get item data from JSON
32
+ - As a JSON Formatter.
33
+ - Get item data from JSON.
34
+ - Support big data.
11
35
12
- ## Links
36
+ ## Environment Support
13
37
14
- - [ Demo] ( https://leezng.github.io/vue-json-pretty )
15
- - [ Github] ( https://github.com/leezng/vue-json-pretty )
16
- - [ NPM] ( https://www.npmjs.com/package/vue-json-pretty )
17
- - [ 中文文档] ( ./README.zh-CN.md )
38
+ - Modern browsers, Electron and Internet Explorer 11 (with polyfills)
39
+ - Server-side Rendering
18
40
19
- ## Install
41
+ | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Electron |
42
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | IE11, Edge | last 10 versions | last 10 versions | last 10 versions | last 2 versions |
44
+
45
+ ## Using NPM or Yarn
20
46
21
47
``` bash
22
- npm install vue-json-pretty --save
48
+ $ npm install vue-json-pretty --save
49
+ ```
50
+
51
+ ``` bash
52
+ $ yarn add vue-json-pretty
23
53
```
24
54
25
55
## Usage
@@ -29,28 +59,23 @@ The CSS file is included separately and needs to be imported manually. You can e
29
59
``` vue
30
60
<template>
31
61
<div>
32
- ...
33
- <vue-json-pretty
34
- :path="'res'"
35
- :data="{ key: 'value' }"
36
- @click="handleClick">
37
- </vue-json-pretty>
62
+ <vue-json-pretty :path="'res'" :data="{ key: 'value' }" @click="handleClick"> </vue-json-pretty>
38
63
</div>
39
64
</template>
40
65
41
66
<script>
42
- import VueJsonPretty from 'vue-json-pretty'
43
- import 'vue-json-pretty/lib/styles.css'
67
+ import VueJsonPretty from 'vue-json-pretty';
68
+ import 'vue-json-pretty/lib/styles.css';
44
69
45
70
export default {
46
71
components: {
47
- VueJsonPretty
48
- }
49
- }
72
+ VueJsonPretty,
73
+ },
74
+ };
50
75
</script>
51
76
```
52
77
53
- ## Nuxt.js
78
+ ## Use Nuxt.js
54
79
55
80
1 . In ` plugins/vue-json-pretty.js `
56
81
@@ -77,31 +102,31 @@ plugins: [
77
102
- If you are using only the normal features (JSON pretty), just focus on the ` base ` properties.
78
103
- If you are using higher features (Get data), you can use ` base ` and ` higher ` attributes.
79
104
80
- | Attribute | Level | Description | Type | Default |
81
- | -------- | -------- | -------- | -------- | -------- |
82
- | data | normal | json data | JSON object | - |
83
- | deep | normal | data depth, data larger than this depth will not be expanded | number | Infinity |
84
- | showLength | normal | whether to show the length when closed | boolean | false |
85
- | showLine | normal | whether to show the line | boolean | true |
86
- | showDoubleQuotes | normal | whether to show doublequotes on key | boolean | true |
87
- | highlightMouseoverNode | normal | highlight current node when mouseover | boolean | false |
88
- | v-model | higher | defines value when the tree can be selected | string, array | -, [ ] |
89
- | path | higher | root data path | string | root |
90
- | pathChecked | higher | defines the selected data path | array | [ ] |
91
- | pathSelectable | higher | defines whether a data path supports selection | Function(itemPath, itemData) | - |
92
- | selectableType | higher | defines the selected type, this feature is not supported by default | enum: -, multiple, single | - |
93
- | showSelectController | higher | whether to show the select controller at left | boolean | false |
94
- | selectOnClickNode | higher | whether to change selected value when click node | boolean | true |
95
- | highlightSelectedNode | higher | highlight current node when selected | boolean | true |
96
- | collapsedOnClickBrackets | higher | collapsed control | boolean | true |
97
- | customValueFormatter | higher | a function that can return different html or strings to display for values in the data. | Function (data, key, parent, defaultFormatted ) | - |
105
+ | Attribute | Level | Description | Type | Default |
106
+ | ------------------------ | ------ | --------------------------------------------------------------------------------------- | -------------------------------------- -------- | -------- |
107
+ | data | normal | JSON data | JSON object | - |
108
+ | deep | normal | Data depth, data larger than this depth will not be expanded | number | Infinity |
109
+ | showLength | normal | Whether to show the length when closed | boolean | false |
110
+ | showLine | normal | Whether to show the line | boolean | true |
111
+ | showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |
112
+ | virtual | normal | Whether to use virtual scrolling, usually used for big data | boolean | false |
113
+ | itemHeight | normal | The height of each item when using virtual scrolling | number | auto |
114
+ | v-model | higher | Defines value when the tree can be selected | string, array | - |
115
+ | path | higher | Root data path | string | root |
116
+ | pathSelectable | higher | Defines whether a data path supports selection | function(path, content) | - |
117
+ | selectableType | higher | Defines the selected type, this feature is not supported by default | multiple, single | - |
118
+ | showSelectController | higher | Whether to show the select controller at left | boolean | false |
119
+ | selectOnClickNode | higher | Whether to change selected value when click node | boolean | true |
120
+ | highlightSelectedNode | higher | Highlight current node when selected | boolean | true |
121
+ | collapsedOnClickBrackets | higher | Collapsed control | boolean | true |
122
+ | customValueFormatter | higher | A function that can return different html or strings to display for values in the data. | function (data, key, path, defaultFormatResult ) | - |
98
123
99
124
## Events
100
125
101
- | Event Name | Description | Callback Parameters |
102
- | ---------- | -------- | ---------- |
103
- | click | triggered when a data item is clicked | (path, data) |
104
- | change | triggered when the selected value changed (only the selectableType not null) | (newVal, oldVal) |
126
+ | Event Name | Description | Callback Parameters |
127
+ | ---------- | ---------------------------------------------------------------------------- | --------- ---------- |
128
+ | click | triggered when a data item is clicked | (path, data) |
129
+ | change | triggered when the selected value changed (only the selectableType not null) | (newVal, oldVal) |
105
130
106
131
## Major Contributors
107
132
0 commit comments