@@ -29,9 +29,10 @@ English | [简体中文](./README.zh_CN.md)
2929## Features
3030
3131- As a JSON Formatter.
32- - Get item data from JSON .
33- - Written in TypeScript with predictable static types .
32+ - Written in TypeScript, support ` d.ts ` .
33+ - Support get item data from JSON .
3434- Support big data.
35+ - Support editable.
3536
3637## Environment Support
3738
@@ -52,10 +53,10 @@ $ npm install vue-json-pretty --save
5253$ yarn add vue-json-pretty
5354```
5455
55- ## Use Vue3
56+ ## Use Vue2
5657
5758``` bash
58- $ npm install vue-json-pretty@next --save
59+ $ npm install vue-json-pretty@v1-latest --save
5960```
6061
6162## Usage
@@ -65,7 +66,7 @@ The CSS file is included separately and needs to be imported manually. You can e
6566``` vue
6667<template>
6768 <div>
68- <vue-json-pretty :path="'res'" : data="{ key: 'value' }" @click="handleClick"> </vue-json-pretty >
69+ <vue-json-pretty :data="{ key: 'value' }" / >
6970 </div>
7071</template>
7172
@@ -105,37 +106,47 @@ plugins: [
105106
106107## Props
107108
108- - If you are using only the normal features (JSON pretty), just focus on the ` base ` properties.
109- - If you are using higher features (Get data), you can use ` base ` and ` higher ` attributes.
110-
111- | Attribute | Level | Description | Type | Default |
112- | ------------------------ | ------ | --------------------------------------------------------------------------------------- | ---------------------------------------------- | -------- |
113- | data | normal | JSON data | JSON object | - |
114- | deep | normal | Data depth, data larger than this depth will not be expanded | number | Infinity |
115- | deepCollapseChildren | normal | Whether children collapsed by ` deep ` prop should also be collapsed | boolean | false |
116- | showLength | normal | Whether to show the length when closed | boolean | false |
117- | showLine | normal | Whether to show the line | boolean | true |
118- | showDoubleQuotes | normal | Whether to show doublequotes on key | boolean | true |
119- | virtual | normal | Whether to use virtual scrolling, usually used for big data | boolean | false |
120- | itemHeight | normal | The height of each item when using virtual scrolling | number | auto |
121- | v-model | higher | Defines value when the tree can be selected | string, array | - |
122- | path | higher | Root data path | string | root |
123- | pathSelectable | higher | Defines whether a data path supports selection | function(path, content) | - |
124- | selectableType | higher | Defines the selected type, this feature is not supported by default | multiple, single | - |
125- | showSelectController | higher | Whether to show the select controller at left | boolean | false |
126- | selectOnClickNode | higher | Whether to change selected value when click node | boolean | true |
127- | highlightSelectedNode | higher | Highlight current node when selected | boolean | true |
128- | collapsedOnClickBrackets | higher | Collapsed control | boolean | true |
129- | customValueFormatter | higher | A function that can return different html or strings to display for values in the data. | function(data, key, path, defaultFormatResult) | - |
109+ | Property | Description | Type | Default |
110+ | ------------------------ | ----------------------------------------------- | --------------------------------- | ------- |
111+ | data(v-model) | JSON data, support v-model when use editable | JSON object | - |
112+ | deep | Paths greater than this depth will be collapsed | number | - |
113+ | showLength | Show the length when collapsed | boolean | false |
114+ | showLine | Show the line | boolean | true |
115+ | showLineNumber | Show the line number | boolean | false |
116+ | showIcon | Show the icon | boolean | false |
117+ | showDoubleQuotes | Show doublequotes on key | boolean | true |
118+ | virtual | Use virtual scroll | boolean | false |
119+ | height | The height of list when using virtual | number | 400 |
120+ | itemHeight | The height of node when using virtual | number | 20 |
121+ | selectedValue(v-model) | Selected data path | string, array | - |
122+ | rootPath | Root data path | string | ` root ` |
123+ | nodeSelectable | Defines whether a node supports selection | (node) => boolean | - |
124+ | selectableType | Support path select, default none | ` multiple ` \| ` single ` | - |
125+ | showSelectController | Show the select controller | boolean | false |
126+ | selectOnClickNode | Trigger select when click node | boolean | true |
127+ | highlightSelectedNode | Support highlighting selected nodes | boolean | true |
128+ | collapsedOnClickBrackets | Support click brackets to collapse | boolean | true |
129+ | renderNodeValue | render node value, or use slot #renderNodeValue | ({ node, defaultValue }) => vNode | - |
130+ | editable | Support editable | boolean | false |
131+ | editableTrigger | Trigger | ` click ` \| ` dblclick ` | ` click ` |
130132
131133## Events
132134
133- | Event Name | Description | Callback Parameters |
134- | ---------- | ---------------------------------------------------------------------------- | ------------------- |
135- | click | triggered when a data item is clicked | (path, data) |
136- | change | triggered when the selected value changed (only the selectableType not null) | (newVal, oldVal) |
135+ | Event Name | Description | Parameters |
136+ | -------------- | ---------------------------------------- | -------------------- |
137+ | nodeClick | triggers when click node | (node: NodeData) |
138+ | bracketsClick | triggers when click brackets | (collapsed: boolean) |
139+ | iconClick | triggers when click icon | (collapsed: boolean) |
140+ | selectedChange | triggers when the selected value changed | (newVal, oldVal) |
137141
138- ## Major Contributors
142+ ## Slots
139143
140- [ ![ ] ( https://avatars3.githubusercontent.com/u/153197?v=3&s=50 )] ( https://github.com/rchl )
141- [ ![ ] ( https://avatars1.githubusercontent.com/u/445616?v=3&s=50 )] ( https://github.com/blackmad )
144+ | Slot Name | Description | Parameters |
145+ | --------------- | ----------------- | ---------------------- |
146+ | renderNodeValue | render node value | { node, defaultValue } |
147+
148+ ## Contributors
149+
150+ <a href =" https://github.com/leezng/vue-json-pretty/graphs/contributors " >
151+ <img src =" https://contrib.rocks/image?repo=leezng/vue-json-pretty " />
152+ </a >
0 commit comments