mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-06-23 20:40:38 +03:00
Merge branch 'develop' into vue3
This commit is contained in:
@@ -160,12 +160,16 @@ import 'vue-json-viewer/style.css'
|
|||||||
| `expanded` | Default expand the view | `false` |
|
| `expanded` | Default expand the view | `false` |
|
||||||
| `timeformat` | custom time format function | time => time.toLocaleString() |
|
| `timeformat` | custom time format function | time => time.toLocaleString() |
|
||||||
| `preview-mode` | no expand mode | `false` |
|
| `preview-mode` | no expand mode | `false` |
|
||||||
|
| `show-array-index` | array show index | `true` |
|
||||||
|
| `show-double-quotes` | show double quotes | `false` |
|
||||||
|
|
||||||
|
|
||||||
## Listeners
|
## Listeners
|
||||||
|
|
||||||
| Listener | Description | Value |
|
| Listener | Description | Value |
|
||||||
| ----------- |:------------- | ----------- |
|
| ----------- |:------------- | ----------- |
|
||||||
| `copied` | Emits copyEvent after text copied | Clipboard success event |
|
| `copied` | Emits copyEvent after text copied | Clipboard success event |
|
||||||
|
| `keyclick` | click key event | |
|
||||||
|
|
||||||
## Slots
|
## Slots
|
||||||
|
|
||||||
@@ -173,6 +177,11 @@ import 'vue-json-viewer/style.css'
|
|||||||
| ----------- |:------------- | ----------- |
|
| ----------- |:------------- | ----------- |
|
||||||
| `copy` | Custom content for copy button | `{copied: boolean}` |
|
| `copy` | Custom content for copy button | `{copied: boolean}` |
|
||||||
|
|
||||||
|
## shortcut keys
|
||||||
|
| Name | Description | Scope |
|
||||||
|
| ----------- |:------------- | ----------- |
|
||||||
|
| `alt` + click | expand all node | |
|
||||||
|
|
||||||
## Theming
|
## Theming
|
||||||
|
|
||||||
To create custom theme, (e.g. `my-awesome-json-theme`), in two easy steps:
|
To create custom theme, (e.g. `my-awesome-json-theme`), in two easy steps:
|
||||||
|
|||||||
@@ -154,6 +154,27 @@ import 'vue-json-viewer/style.css'
|
|||||||
| `expanded` | 默认展开视图 | `false` |
|
| `expanded` | 默认展开视图 | `false` |
|
||||||
| `timeformat` | 自定义时间格式函数 | time => time.toLocaleString() |
|
| `timeformat` | 自定义时间格式函数 | time => time.toLocaleString() |
|
||||||
| `preview-mode` | 不可折叠模式,默认全部展开 | `false` |
|
| `preview-mode` | 不可折叠模式,默认全部展开 | `false` |
|
||||||
|
| `show-array-index` | 是否显示数组索引 | `true` |
|
||||||
|
| `show-double-quotes` | 展示key双引号 | `false` |
|
||||||
|
|
||||||
|
|
||||||
|
## 事件
|
||||||
|
|
||||||
|
| 事件 | 描述 | 值 |
|
||||||
|
| ----------- |:------------- | ----------- |
|
||||||
|
| `copied` | 复制文本后的事件 | |
|
||||||
|
| `keyclick` | 点击key的事件 | |
|
||||||
|
|
||||||
|
## Slots
|
||||||
|
|
||||||
|
| 名称 | 描述 | Scope |
|
||||||
|
| ----------- |:------------- | ----------- |
|
||||||
|
| `copy` | 自定义拷贝按钮 | `{copied: boolean}` |
|
||||||
|
|
||||||
|
## 快捷键
|
||||||
|
| 名称 | 描述 |
|
||||||
|
| ----------- |:------------- |
|
||||||
|
| `alt` + click | 展开当前节点下的所有节点 |
|
||||||
|
|
||||||
## 主题
|
## 主题
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
boxed
|
boxed
|
||||||
:timeformat="(time) => new Date(time)"
|
:timeformat="(time) => new Date(time)"
|
||||||
sort
|
sort
|
||||||
|
show-double-quotes
|
||||||
|
:show-array-index="false"
|
||||||
|
:onKeyclick="onKeyclick"
|
||||||
></json-viewer>
|
></json-viewer>
|
||||||
<hr />
|
<hr />
|
||||||
<json-viewer
|
<json-viewer
|
||||||
@@ -101,6 +104,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
onCopied(copyEvent) {
|
onCopied(copyEvent) {
|
||||||
alert(`Text successfully copied!\n${copyEvent.text}`);
|
alert(`Text successfully copied!\n${copyEvent.text}`);
|
||||||
|
},
|
||||||
|
onKeyclick(path) {
|
||||||
|
alert(`Key Click!\n${path}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+12
-2
@@ -11,7 +11,7 @@ import JsonDate from './types/json-date'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JsonBox',
|
name: 'JsonBox',
|
||||||
inject: ['expandDepth'],
|
inject: ['expandDepth', 'onKeyclick'],
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [Object, Array, String, Number, Boolean, Function, Date],
|
type: [Object, Array, String, Number, Boolean, Function, Date],
|
||||||
@@ -29,6 +29,11 @@ export default {
|
|||||||
previewMode: Boolean,
|
previewMode: Boolean,
|
||||||
forceExpand: Boolean,
|
forceExpand: Boolean,
|
||||||
showArrayIndex: Boolean,
|
showArrayIndex: Boolean,
|
||||||
|
showDoubleQuotes: Boolean,
|
||||||
|
path: {
|
||||||
|
type: String,
|
||||||
|
default: '$',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -117,7 +122,10 @@ export default {
|
|||||||
class: {
|
class: {
|
||||||
'jv-key': true
|
'jv-key': true
|
||||||
},
|
},
|
||||||
innerText: `${this.keyName}:`
|
innerText: this.showDoubleQuotes ? `"${this.keyName}":` : `${this.keyName}:`,
|
||||||
|
onClick: () => {
|
||||||
|
this.onKeyclick(this.path);
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +141,8 @@ export default {
|
|||||||
previewMode: this.previewMode,
|
previewMode: this.previewMode,
|
||||||
forceExpand: this.forceExpandMe,
|
forceExpand: this.forceExpandMe,
|
||||||
showArrayIndex: this.showArrayIndex,
|
showArrayIndex: this.showArrayIndex,
|
||||||
|
showDoubleQuotes: this.showDoubleQuotes,
|
||||||
|
path: this.path,
|
||||||
'onUpdate:expand': value => {
|
'onUpdate:expand': value => {
|
||||||
this.expand = value
|
this.expand = value
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
:sort="sort"
|
:sort="sort"
|
||||||
:preview-mode="previewMode"
|
:preview-mode="previewMode"
|
||||||
:show-array-index="showArrayIndex"
|
:show-array-index="showArrayIndex"
|
||||||
|
:show-double-quotes="showDoubleQuotes"
|
||||||
|
@keyclick="onKeyclick"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -96,12 +98,17 @@ export default {
|
|||||||
showArrayIndex: {
|
showArrayIndex: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
},
|
||||||
|
showDoubleQuotes: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
provide () {
|
provide () {
|
||||||
return {
|
return {
|
||||||
expandDepth: this.expandDepth,
|
expandDepth: this.expandDepth,
|
||||||
timeformat: this.timeformat,
|
timeformat: this.timeformat,
|
||||||
|
onKeyclick: this.onKeyclick,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
@@ -175,6 +182,9 @@ export default {
|
|||||||
},
|
},
|
||||||
toggleExpandCode () {
|
toggleExpandCode () {
|
||||||
this.expandCode = !this.expandCode
|
this.expandCode = !this.expandCode
|
||||||
|
},
|
||||||
|
onKeyclick(path) {
|
||||||
|
this.$emit('keyclick', path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ export default {
|
|||||||
forceExpand: Boolean,
|
forceExpand: Boolean,
|
||||||
previewMode: Boolean,
|
previewMode: Boolean,
|
||||||
showArrayIndex: Boolean,
|
showArrayIndex: Boolean,
|
||||||
|
showDoubleQuotes: Boolean,
|
||||||
|
path: String,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -107,6 +109,8 @@ export default {
|
|||||||
previewMode: this.previewMode,
|
previewMode: this.previewMode,
|
||||||
forceExpand: this.forceExpand,
|
forceExpand: this.forceExpand,
|
||||||
showArrayIndex: this.showArrayIndex,
|
showArrayIndex: this.showArrayIndex,
|
||||||
|
showDoubleQuotes: this.showDoubleQuotes,
|
||||||
|
path: `${this.path}.${key}`,
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ export default {
|
|||||||
sort: Boolean,
|
sort: Boolean,
|
||||||
previewMode: Boolean,
|
previewMode: Boolean,
|
||||||
showArrayIndex: Boolean,
|
showArrayIndex: Boolean,
|
||||||
|
showDoubleQuotes: Boolean,
|
||||||
|
path: String,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -118,6 +120,8 @@ export default {
|
|||||||
previewMode: this.previewMode,
|
previewMode: this.previewMode,
|
||||||
forceExpand: this.forceExpand,
|
forceExpand: this.forceExpand,
|
||||||
showArrayIndex: this.showArrayIndex,
|
showArrayIndex: this.showArrayIndex,
|
||||||
|
showDoubleQuotes: this.showDoubleQuotes,
|
||||||
|
path: `${this.path}.${key}`
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-json-viewer",
|
"name": "vue-json-viewer",
|
||||||
"version": "3.0.2",
|
"version": "3.0.3",
|
||||||
"description": "vuejs展示json的组件",
|
"description": "vuejs展示json的组件",
|
||||||
"main": "vue-json-viewer.js",
|
"main": "vue-json-viewer.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
Reference in New Issue
Block a user