Skip to content

Commit fa11d6d

Browse files
committed
fix: When there is a . Character on the path, an error occurs when parsing the path. closed #63
1 parent ab6688a commit fa11d6d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
},
8080
"browserslist": [
8181
"> 1%",
82-
"last 5 versions",
82+
"last 10 versions",
8383
"not ie <= 11"
8484
],
8585
"files": [

src/components/app.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
v-if="currentDeep > 1 && !Array.isArray(parentData)"
4141
class="vjs-key"
4242
>
43-
{{ keyFormatter(currentKey) }}:
43+
{{ prettyKey }}:
4444
</span>
4545
</brackets-left>
4646

@@ -64,7 +64,7 @@
6464
:show-line="showLine"
6565
:highlight-mouseover-node="highlightMouseoverNode"
6666
:highlight-selected-node="highlightSelectedNode"
67-
:path="path + (Array.isArray(data) ? `[${key}]` : `.${key}`)"
67+
:path="getChildPath(key)"
6868
:path-selectable="pathSelectable"
6969
:selectable-type="selectableType"
7070
:show-select-controller="showSelectController"
@@ -100,7 +100,7 @@
100100
v-if="parentData && currentKey && !Array.isArray(parentData)"
101101
class="vjs-key"
102102
>
103-
{{ keyFormatter(currentKey) }}:
103+
{{ prettyKey }}:
104104
</span>
105105
</simple-text>
106106
</div>
@@ -279,6 +279,10 @@
279279
}
280280
},
281281
282+
prettyKey () {
283+
return this.showDoubleQuotes ? `"${this.currentKey}"` : this.currentKey
284+
},
285+
282286
propsError () {
283287
const error = this.selectableType && !this.selectOnClickNode && !this.showSelectController
284288
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.' : ''
@@ -367,8 +371,8 @@
367371
return getDataType(value) === 'object'
368372
},
369373
370-
keyFormatter (key) {
371-
return this.showDoubleQuotes ? `"${key}"` : key
374+
getChildPath (key) {
375+
return this.path + (Array.isArray(this.data) ? `[${key}]` : key.includes('.') ? `["${key}"]` : `.${key}`)
372376
}
373377
},
374378
// 捕获一个来自子组件的错误

src/utils/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// 获取数据类型
22
export function getDataType (value) {
3-
// 若使用 typeof 会影响 webpack 压缩后体积变大
43
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase()
54
}

0 commit comments

Comments
 (0)