-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathObjectTreeNode.vue
50 lines (47 loc) · 1.21 KB
/
ObjectTreeNode.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
<objectTreeNodePrimitive v-if="primitive" v-model="value" :type="type" />
<objectTreeNodeComplex v-else v-model="value" :type="type" :primary="primary" :nowrap="nowrap" :expandButtonText="expandButtonText" />
</template>
<script>
import objectTreeNodeComplex from './ObjectTreeNodeComplex.vue';
import objectTreeNodePrimitive from './ObjectTreeNodePrimitive.vue';
export default {
name: 'objectTreeNode',
props: {
value: [String, Number, Array, Function, Boolean, Object],
primary: Boolean,
expandButtonText: {
type: String,
default: '...'
},
nowrap: {
type: Boolean,
default: true
}
},
computed: {
type() {
let _type = typeof(this.value);
if (_type == 'object') {
if (this.value == null) {
return "null";
}
if (Array.isArray(this.value)) {
return "array";
}
return "object";
}
return _type;
},
primitive() {
return !(this.type === 'array' || this.type === 'object');
}
},
components: {
objectTreeNodeComplex,
objectTreeNodePrimitive
}
}
</script>
<style scoped>
</style>