mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-06-20 20:00:37 +03:00
feat: Add PreviewMode
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## 2.2.14 2020-10-13
|
||||||
|
|
||||||
|
- Add Preview Mode
|
||||||
|
|
||||||
## 2.2.14 2020-07-27
|
## 2.2.14 2020-07-27
|
||||||
|
|
||||||
- Allow add specific style for float and integer numbers [pr](https://github.com/chenfengjw163/vue-json-viewer/pull/51)
|
- Allow add specific style for float and integer numbers [pr](https://github.com/chenfengjw163/vue-json-viewer/pull/51)
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ import 'vue-json-viewer/style.css'
|
|||||||
| `theme` | Add a custom CSS class for theming purposes | `jv-light` |
|
| `theme` | Add a custom CSS class for theming purposes | `jv-light` |
|
||||||
| `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` |
|
||||||
|
|
||||||
## Listeners
|
## Listeners
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ import 'vue-json-viewer/style.css'
|
|||||||
| `theme` | 添加一个自定义的样式class用作主题 | `jv-light` |
|
| `theme` | 添加一个自定义的样式class用作主题 | `jv-light` |
|
||||||
| `expanded` | 默认展开视图 | `false` |
|
| `expanded` | 默认展开视图 | `false` |
|
||||||
| `timeformat` | 自定义时间格式函数 | time => time.toLocaleString() |
|
| `timeformat` | 自定义时间格式函数 | time => time.toLocaleString() |
|
||||||
|
| `preview-mode` | 不可折叠模式,默认全部展开 | `false` |
|
||||||
|
|
||||||
## 主题
|
## 主题
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ new Vue({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
<json-viewer
|
||||||
|
preview-mode
|
||||||
|
value={{
|
||||||
|
data: {
|
||||||
|
data: {
|
||||||
|
data: {
|
||||||
|
a: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}></json-viewer>
|
||||||
<json-viewer value={this.jsonData}></json-viewer>
|
<json-viewer value={this.jsonData}></json-viewer>
|
||||||
<hr />
|
<hr />
|
||||||
<json-viewer
|
<json-viewer
|
||||||
|
|||||||
+7
-5
@@ -24,7 +24,8 @@ export default {
|
|||||||
depth: {
|
depth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
}
|
},
|
||||||
|
previewMode: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -32,7 +33,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.expand = this.depth >= this.expandDepth ? false : true
|
this.expand = this.previewMode || (this.depth >= this.expandDepth ? false : true)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggle() {
|
toggle() {
|
||||||
@@ -71,7 +72,7 @@ export default {
|
|||||||
}
|
}
|
||||||
const toggle = this.keyName && (this.value && (Array.isArray(this.value) || (typeof this.value === 'object' && Object.prototype.toString.call(this.value) !== '[object Date]')))
|
const toggle = this.keyName && (this.value && (Array.isArray(this.value) || (typeof this.value === 'object' && Object.prototype.toString.call(this.value) !== '[object Date]')))
|
||||||
|
|
||||||
if (toggle) {
|
if (!this.previewMode && toggle) {
|
||||||
elements.push(h('span', {
|
elements.push(h('span', {
|
||||||
class: {
|
class: {
|
||||||
'jv-toggle': true,
|
'jv-toggle': true,
|
||||||
@@ -103,7 +104,8 @@ export default {
|
|||||||
keyName: this.keyName,
|
keyName: this.keyName,
|
||||||
sort: this.sort,
|
sort: this.sort,
|
||||||
depth: this.depth,
|
depth: this.depth,
|
||||||
expand: this.expand
|
expand: this.expand,
|
||||||
|
previewMode: this.previewMode,
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
'update:expand': value => {
|
'update:expand': value => {
|
||||||
@@ -115,7 +117,7 @@ export default {
|
|||||||
return h('div', {
|
return h('div', {
|
||||||
class: {
|
class: {
|
||||||
'jv-node': true,
|
'jv-node': true,
|
||||||
'toggle': toggle
|
'toggle': !this.previewMode && toggle
|
||||||
}
|
}
|
||||||
}, elements)
|
}, elements)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
ref="jsonBox"
|
ref="jsonBox"
|
||||||
:value="value"
|
:value="value"
|
||||||
:sort="sort"
|
:sort="sort"
|
||||||
|
:preview-mode="previewMode"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -83,6 +84,10 @@ export default {
|
|||||||
timeformat: {
|
timeformat: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: value => value.toLocaleString(),
|
default: value => value.toLocaleString(),
|
||||||
|
},
|
||||||
|
previewMode: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
provide () {
|
provide () {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ export default {
|
|||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
sort: Boolean,
|
sort: Boolean,
|
||||||
expand: Boolean
|
expand: Boolean,
|
||||||
|
previewMode: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -61,7 +62,7 @@ export default {
|
|||||||
render (h) {
|
render (h) {
|
||||||
let elements = []
|
let elements = []
|
||||||
|
|
||||||
if (!this.keyName) {
|
if (!this.previewMode && !this.keyName) {
|
||||||
elements.push(h('span', {
|
elements.push(h('span', {
|
||||||
class: {
|
class: {
|
||||||
'jv-toggle': true,
|
'jv-toggle': true,
|
||||||
@@ -94,6 +95,7 @@ export default {
|
|||||||
// keyName: key,
|
// keyName: key,
|
||||||
depth: this.depth + 1,
|
depth: this.depth + 1,
|
||||||
value,
|
value,
|
||||||
|
previewMode: this.previewMode,
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ export default {
|
|||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
expand: Boolean,
|
expand: Boolean,
|
||||||
sort: Boolean
|
sort: Boolean,
|
||||||
|
previewMode: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -69,7 +70,7 @@ export default {
|
|||||||
render (h) {
|
render (h) {
|
||||||
let elements = []
|
let elements = []
|
||||||
|
|
||||||
if (!this.keyName) {
|
if (!this.previewMode && !this.keyName) {
|
||||||
elements.push(h('span', {
|
elements.push(h('span', {
|
||||||
class: {
|
class: {
|
||||||
'jv-toggle': true,
|
'jv-toggle': true,
|
||||||
@@ -106,6 +107,7 @@ export default {
|
|||||||
keyName: key,
|
keyName: key,
|
||||||
depth: this.depth + 1,
|
depth: this.depth + 1,
|
||||||
value,
|
value,
|
||||||
|
previewMode: this.previewMode,
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-json-viewer",
|
"name": "vue-json-viewer",
|
||||||
"version": "2.2.14",
|
"version": "2.2.15",
|
||||||
"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