Skip to content

Commit 13c7e39

Browse files
committed
Add class "vjs-key", "vjs-value" to node. #20
1 parent 2fe8d28 commit 13c7e39

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/components/app.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'has-selectable-control': isMultiple || showSelectController,
66
'is-root': currentDeep === 1,
77
'is-selectable': selectable,
8+
'is-selected': isSelected,
89
'is-mouseover': isMouseover
910
}"
1011
@click.stop="handleClick($event, 'tree')"
@@ -22,7 +23,7 @@
2223
:data="data"
2324
:show-length="showLength"
2425
:show-comma="notLastKey">
25-
<span v-if="currentDeep > 1 && !Array.isArray(parentData)">{{ keyFormatter(currentKey) }}:</span>
26+
<span v-if="currentDeep > 1 && !Array.isArray(parentData)" class="vjs-key">{{ keyFormatter(currentKey) }}:</span>
2627
</brackets-left>
2728

2829
<!-- 数据内容, data 为对象时, key 表示键名, 为数组时表示索引 -->
@@ -66,7 +67,7 @@
6667
:parent-data="parentData"
6768
:data="data"
6869
:current-key="currentKey">
69-
<span v-if="!Array.isArray(parentData)">{{ keyFormatter(currentKey) }}:</span>
70+
<span v-if="!Array.isArray(parentData)" class="vjs-key">{{ keyFormatter(currentKey) }}:</span>
7071
</simple-text>
7172
</div>
7273
</template>
@@ -205,6 +206,16 @@
205206
return this.selectableType === 'single'
206207
},
207208
209+
isSelected () {
210+
if (this.isMultiple) {
211+
return this.model.includes(this.path)
212+
} else if (this.isSingle) {
213+
return this.model === this.path
214+
} else {
215+
return false
216+
}
217+
},
218+
208219
propsError () {
209220
const error = this.selectableType && !this.selectOnClickNode && !this.showSelectController
210221
return error ? 'When selectableType is not null, selectOnClickNode and showSelectController cannot be false at the same time, because this will cause the selection to fail.' : ''

src/components/simple-text.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<slot></slot>
4-
<span :class="`vjs-value__${dataType}`">
4+
<span :class="`vjs-value vjs-value__${dataType}`">
55
{{ textFormatter(data) }}
66
</span>
77
</div>

0 commit comments

Comments
 (0)