diff --git a/README.md b/README.md index a97e290..0acbc66 100644 --- a/README.md +++ b/README.md @@ -161,6 +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 | `false` | ## Listeners @@ -168,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 diff --git a/README_CN.md b/README_CN.md index 68e1f64..9244dc3 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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 diff --git a/example/app.js b/example/app.js index 4409a71..6203ef6 100644 --- a/example/app.js +++ b/example/app.js @@ -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 (
new Date(time)} - sort> + sort + onKeyclick={onKeyclick} + >
{ + this.onKeyclick(this.path); + } } })) } @@ -137,6 +147,8 @@ export default { previewMode: this.previewMode, forceExpand: this.forceExpandMe, showArrayIndex: this.showArrayIndex, + showDoubleQuotes: this.showDoubleQuotes, + path: this.path, }, on: { 'update:expand': value => { diff --git a/lib/json-viewer.vue b/lib/json-viewer.vue index 5365041..0ead5b6 100644 --- a/lib/json-viewer.vue +++ b/lib/json-viewer.vue @@ -30,6 +30,8 @@ :sort="sort" :preview-mode="previewMode" :show-array-index="showArrayIndex" + :show-double-quotes="showDoubleQuotes" + @keyclick="onKeyclick" />