mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-06-11 18:02:29 +03:00
add support for 'null' values in json objects
This commit is contained in:
+3
-2
@@ -15,10 +15,11 @@ new Vue({
|
||||
b: 'a',
|
||||
a: 'hello word',
|
||||
asd2: 1,
|
||||
asd: false
|
||||
asd: false,
|
||||
foo: null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
components: {JsonViewer}
|
||||
})
|
||||
})
|
||||
|
||||
+4
-1
@@ -11,6 +11,7 @@
|
||||
<script>
|
||||
import JIcon from './json-icon'
|
||||
import JsonString from './types/json-string';
|
||||
import JsonNull from './types/json-null';
|
||||
import JsonNumber from './types/json-number';
|
||||
import JsonBoolean from './types/json-boolean';
|
||||
import JsonObject from './types/json-object';
|
||||
@@ -34,7 +35,9 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
valueType() {
|
||||
if (Array.isArray(this.value)) {
|
||||
if (this.value === null) {
|
||||
return 'Null';
|
||||
} else if (Array.isArray(this.value)) {
|
||||
return 'Array';
|
||||
} else if (typeof this.value === 'object') {
|
||||
return 'Object';
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<span class="json-null">null</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'JsonNull',
|
||||
props: {
|
||||
jsonValue: Object
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.json-null {
|
||||
color: #e08331;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user