mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-05-15 11:59:40 +03:00
+2.2.22
This commit is contained in:
@@ -161,7 +161,7 @@ import 'vue-json-viewer/style.css'
|
||||
| `timeformat` | custom time format function | time => time.toLocaleString() |
|
||||
| `preview-mode` | no expand mode | `false` |
|
||||
| `show-array-index` | array show index | `true` |
|
||||
| `show-double-quotes` | show double quotes | `true` |
|
||||
| `show-double-quotes` | show double quotes | `false` |
|
||||
|
||||
|
||||
## Listeners
|
||||
@@ -169,6 +169,7 @@ import 'vue-json-viewer/style.css'
|
||||
| Listener | Description | Value |
|
||||
| ----------- |:------------- | ----------- |
|
||||
| `copied` | Emits copyEvent after text copied | Clipboard success event |
|
||||
| `keyclick` | click key event | |
|
||||
|
||||
## Slots
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ import 'vue-json-viewer/style.css'
|
||||
| `timeformat` | 自定义时间格式函数 | time => time.toLocaleString() |
|
||||
| `preview-mode` | 不可折叠模式,默认全部展开 | `false` |
|
||||
| `show-array-index` | 是否显示数组索引 | `true` |
|
||||
| `show-double-quotes` | 展示key双引号 | `false` |
|
||||
|
||||
|
||||
## 事件
|
||||
@@ -162,6 +163,7 @@ import 'vue-json-viewer/style.css'
|
||||
| 事件 | 描述 | 值 |
|
||||
| ----------- |:------------- | ----------- |
|
||||
| `copied` | 复制文本后的事件 | |
|
||||
| `keyclick` | 点击key的事件 | |
|
||||
|
||||
## Slots
|
||||
|
||||
|
||||
+7
-1
@@ -16,6 +16,9 @@ new Vue({
|
||||
const onCopied = (copyEvent) => {
|
||||
alert(`Text successfully copied!\n${copyEvent.text}`);
|
||||
}
|
||||
const onKeyclick = (path) => {
|
||||
alert(`Key Click!\n${path}`);
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<json-viewer
|
||||
@@ -40,9 +43,12 @@ new Vue({
|
||||
align: 'left'
|
||||
}}
|
||||
boxed
|
||||
show-double-quotes
|
||||
show-array-index={false}
|
||||
timeformat={time => new Date(time)}
|
||||
sort></json-viewer>
|
||||
sort
|
||||
onKeyclick={onKeyclick}
|
||||
></json-viewer>
|
||||
<hr />
|
||||
<json-viewer
|
||||
value={this.jsonData}
|
||||
|
||||
+11
-1
@@ -10,7 +10,7 @@ import JsonDate from './types/json-date'
|
||||
|
||||
export default {
|
||||
name: 'JsonBox',
|
||||
inject: ['expandDepth'],
|
||||
inject: ['expandDepth', 'onKeyclick'],
|
||||
props: {
|
||||
value: {
|
||||
type: [Object, Array, String, Number, Boolean, Function, Date],
|
||||
@@ -29,6 +29,10 @@ export default {
|
||||
forceExpand: Boolean,
|
||||
showArrayIndex: Boolean,
|
||||
showDoubleQuotes: Boolean,
|
||||
path: {
|
||||
type: String,
|
||||
default: '$',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -121,6 +125,11 @@ export default {
|
||||
},
|
||||
domProps: {
|
||||
innerText: this.showDoubleQuotes ? `"${this.keyName}":` : `${this.keyName}:`
|
||||
},
|
||||
on: {
|
||||
click: () => {
|
||||
this.onKeyclick(this.path);
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -139,6 +148,7 @@ export default {
|
||||
forceExpand: this.forceExpandMe,
|
||||
showArrayIndex: this.showArrayIndex,
|
||||
showDoubleQuotes: this.showDoubleQuotes,
|
||||
path: this.path,
|
||||
},
|
||||
on: {
|
||||
'update:expand': value => {
|
||||
|
||||
+6
-1
@@ -31,6 +31,7 @@
|
||||
:preview-mode="previewMode"
|
||||
:show-array-index="showArrayIndex"
|
||||
:show-double-quotes="showDoubleQuotes"
|
||||
@keyclick="onKeyclick"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
@@ -100,13 +101,14 @@ export default {
|
||||
},
|
||||
showDoubleQuotes: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
provide () {
|
||||
return {
|
||||
expandDepth: this.expandDepth,
|
||||
timeformat: this.timeformat,
|
||||
onKeyclick: this.onKeyclick,
|
||||
}
|
||||
},
|
||||
data () {
|
||||
@@ -180,6 +182,9 @@ export default {
|
||||
},
|
||||
toggleExpandCode () {
|
||||
this.expandCode = !this.expandCode
|
||||
},
|
||||
onKeyclick(path) {
|
||||
this.$emit('keyclick', path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ export default {
|
||||
previewMode: Boolean,
|
||||
showArrayIndex: Boolean,
|
||||
showDoubleQuotes: Boolean,
|
||||
path: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -110,6 +111,7 @@ export default {
|
||||
forceExpand: this.forceExpand,
|
||||
showArrayIndex: this.showArrayIndex,
|
||||
showDoubleQuotes: this.showDoubleQuotes,
|
||||
path: `${this.path}.${key}`,
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -22,6 +22,7 @@ export default {
|
||||
previewMode: Boolean,
|
||||
showArrayIndex: Boolean,
|
||||
showDoubleQuotes: Boolean,
|
||||
path: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -121,6 +122,7 @@ export default {
|
||||
forceExpand: this.forceExpand,
|
||||
showArrayIndex: this.showArrayIndex,
|
||||
showDoubleQuotes: this.showDoubleQuotes,
|
||||
path: `${this.path}.${key}`
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
+14
-4
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"name": "vue-json-viewer",
|
||||
"version": "2.2.21",
|
||||
"version": "2.2.22",
|
||||
"description": "vuejs展示json的组件",
|
||||
"main": "vue-json-viewer.js",
|
||||
"files": ["vue-json-viewer.js", "ssr.js", "style.css"],
|
||||
"files": [
|
||||
"vue-json-viewer.js",
|
||||
"ssr.js",
|
||||
"style.css"
|
||||
],
|
||||
"directories": {
|
||||
"lib": "./lib",
|
||||
"example": "./example"
|
||||
@@ -18,7 +22,10 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chenfengjw163/vue-json-viewer.git"
|
||||
},
|
||||
"keywords": ["vue", "json"],
|
||||
"keywords": [
|
||||
"vue",
|
||||
"json"
|
||||
],
|
||||
"homepage": "https://github.com/chenfengjw163/vue-json-viewer#readme",
|
||||
"author": {
|
||||
"name": "陈峰",
|
||||
@@ -77,5 +84,8 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^2.6.9"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user