You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-5Lines changed: 36 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,15 @@ A vue 2.x component for rendering JSON data as a tree structure.
18
18
19
19
## Install
20
20
21
-
```js
22
-
npm install vue-json-pretty
21
+
```bash
22
+
npm install vue-json-pretty --save
23
23
```
24
24
25
25
## Usage
26
26
27
-
```html
27
+
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.
28
+
29
+
```vue
28
30
<template>
29
31
<div>
30
32
...
@@ -35,16 +37,39 @@ npm install vue-json-pretty
35
37
</vue-json-pretty>
36
38
</div>
37
39
</template>
38
-
```
39
40
40
-
```js
41
+
<script>
41
42
import VueJsonPretty from 'vue-json-pretty'
43
+
import 'vue-json-pretty/lib/styles.css';
42
44
43
45
export default {
44
46
components: {
45
47
VueJsonPretty
46
48
}
47
49
}
50
+
</script>
51
+
```
52
+
53
+
## Nuxt.js
54
+
55
+
1. In `plugins/vue-json-pretty.js`
56
+
57
+
```
58
+
import Vue from 'vue'
59
+
import VueJsonPretty from 'vue-json-pretty'
60
+
61
+
Vue.component("vue-json-pretty", VueJsonPretty);
62
+
```
63
+
64
+
2. In `nuxt.config.js`
65
+
66
+
```js
67
+
css: [
68
+
'vue-json-pretty/lib/styles.css'
69
+
],
70
+
plugins: [
71
+
'@/plugins/vue-json-pretty'
72
+
],
48
73
```
49
74
50
75
## Props
@@ -68,6 +93,7 @@ export default {
68
93
| showSelectController | higher | whether to show the select controller at left | boolean | false |
69
94
| selectOnClickNode | higher | whether to change selected value when click node | boolean | true |
70
95
| highlightSelectedNode | higher | highlight current node when selected | boolean | true |
| customValueFormatter | higher | a function that can return different html or strings to display for values in the data. | Function(data, key, parent, defaultFormatted) | - |
72
98
73
99
## Events
@@ -76,3 +102,8 @@ export default {
76
102
|---------- |-------- |---------- |
77
103
| click | triggered when a data item is clicked | (path, data) |
78
104
| change | triggered when the selected value changed (only the selectableType not null) | (newVal, oldVal) |
0 commit comments