mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-06-20 20:00:37 +03:00
feat: add timeformat props
This commit is contained in:
@@ -3,11 +3,6 @@ import JsonBox from '../json-box'
|
||||
|
||||
export default {
|
||||
name: 'JsonArray',
|
||||
data() {
|
||||
return {
|
||||
value: []
|
||||
}
|
||||
},
|
||||
props: {
|
||||
jsonValue: {
|
||||
type: Array,
|
||||
@@ -24,6 +19,11 @@ export default {
|
||||
sort: Boolean,
|
||||
expand: Boolean
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
value: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
jsonValue(newVal) {
|
||||
this.setValue(newVal);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
export default {
|
||||
name: 'JsonDate',
|
||||
inject: ['timeformat'],
|
||||
functional: true,
|
||||
props: {
|
||||
jsonValue: {
|
||||
@@ -8,8 +9,9 @@ export default {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
render (h, { props }) {
|
||||
render (h, { props, injections }) {
|
||||
const value = props.jsonValue;
|
||||
const timeformat = injections.timeformat;
|
||||
|
||||
return h('span', {
|
||||
class: {
|
||||
@@ -17,7 +19,7 @@ export default {
|
||||
'jv-string': true,
|
||||
},
|
||||
domProps: {
|
||||
innerText: `"${value.toLocaleString()}"`
|
||||
innerText: `"${timeformat(value)}"`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,11 +3,6 @@ import JsonBox from '../json-box'
|
||||
|
||||
export default {
|
||||
name: 'JsonObject',
|
||||
data() {
|
||||
return {
|
||||
value: {}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
jsonValue: {
|
||||
type: Object,
|
||||
@@ -24,6 +19,11 @@ export default {
|
||||
expand: Boolean,
|
||||
sort: Boolean
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
value: {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
ordered () {
|
||||
if (!this.sort) {
|
||||
|
||||
Reference in New Issue
Block a user