Skip to content

Commit 9d22bfa

Browse files
committed
修复deep属性没有实时响应的问题
1 parent efd0f9d commit 9d22bfa

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-json-pretty",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "A Vue.js 2.0 Toolkit for JSON",
55
"author": "leezng <im.leezng@gmail.com>",
66
"main": "vue-json-pretty.js",
@@ -89,8 +89,5 @@
8989
"> 1%",
9090
"last 2 versions",
9191
"not ie <= 8"
92-
],
93-
"dependencies": {
94-
"vue": "^2.3.0"
95-
}
92+
]
9693
}

src/components/app.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<template v-if="Array.isArray(data) || isObject(data)">
1717
<!-- 左闭合 -->
1818
<brackets-left
19-
:visiable.sync="visiable"
19+
:visible.sync="visible"
2020
:data="data"
2121
:show-length="showLength"
2222
:not-last-key="notLastKey">
@@ -26,7 +26,7 @@
2626
<!-- 数据内容, data 为对象时, key 表示键名, 为数组时表示索引 -->
2727
<div
2828
v-for="(item, key) in data"
29-
v-show="visiable"
29+
v-show="visible"
3030
class="vjs__tree__content"
3131
:key="key">
3232
<vue-json-pretty
@@ -46,7 +46,7 @@
4646

4747
<!-- 右闭合 -->
4848
<brackets-right
49-
:visiable.sync="visiable"
49+
:visible.sync="visible"
5050
:data="data"
5151
:not-last-key="notLastKey">
5252
</brackets-right>
@@ -125,7 +125,7 @@
125125
},
126126
data () {
127127
return {
128-
visiable: this.currentDeep <= this.deep,
128+
visible: this.currentDeep <= this.deep,
129129
treeContentBackground: 'transparent',
130130
checkboxVal: this.pathChecked.includes(this.path) // 复选框的值
131131
}
@@ -187,6 +187,11 @@
187187
// 若使用 typeof 会影响 webpack 压缩后体积变大
188188
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase()
189189
}
190+
},
191+
watch: {
192+
deep (newVal) {
193+
this.visible = this.currentDeep <= newVal
194+
}
190195
}
191196
}
192197
</script>

src/mixins/brackets-mixin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
props: {
3-
visiable: {
3+
visible: {
44
required: true,
55
type: Boolean
66
},
@@ -12,10 +12,10 @@ export default {
1212
computed: {
1313
dataVisiable: {
1414
get () {
15-
return this.visiable
15+
return this.visible
1616
},
1717
set (val) {
18-
this.$emit('update:visiable', val)
18+
this.$emit('update:visible', val)
1919
}
2020
}
2121
},

0 commit comments

Comments
 (0)