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