Skip to content

Commit 76f0fb6

Browse files
committed
docs: boolean attrs
1 parent 64c501e commit 76f0fb6

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,15 @@ export default {
259259
| ------- | --------------------------------------------------------------------------------------------- | ------------------ | -------- |
260260
| v-model | binding value | `any` | |
261261
| mode | edit mode, use `v-model:mode` in Vue 3 or `:mode.sync` in Vue 2 | `'tree'`, `'text'` | `'tree'` |
262-
| ... | properties of [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) | | |
262+
| ... | properties of [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) (via attrs) | | |
263+
264+
### Boolean Attrs
265+
266+
Boolean properties of `svelte-jsoneditor` like `readOnly` won't imply `true` because they are [attrs](https://vuejs.org/guide/components/attrs.html):
267+
268+
- ✔️ `<json-editor-vue :readOnly="true" />`
269+
270+
-`<json-editor-vue readOnly />`
263271

264272
<br>
265273

docs/README.zh-CN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,15 @@ export default {
257257
| ------- | -------------------------------------------------------------------------------------- | ------------------ | -------- |
258258
| v-model | 绑定值 | `any` | |
259259
| mode | 编辑模式,在 Vue 3 中使用 `v-model:mode`,在 Vue 2 中使用 `:mode.sync` | `'tree'`, `'text'` | `'tree'` |
260-
| ... | [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) 的参数 | | |
260+
| ... | [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) 的参数(通过 attrs) | | |
261+
262+
### 布尔类型的 Attrs
263+
264+
`svelte-jsoneditor` 的布尔类型参数如 `readOnly` 不会隐式转换为 `true`,因为它们是 [attrs](https://vuejs.org/guide/components/attrs.html):
265+
266+
- ✔️ `<json-editor-vue :readOnly="true" />`
267+
268+
-`<json-editor-vue readOnly />`
261269

262270
<br>
263271

src/Component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export default defineComponent({
9797
})
9898
})
9999

100-
watch(() => attrs, (props) => {
101-
jsonEditor.value.updateProps(props)
100+
watch(() => attrs, (attrs) => {
101+
jsonEditor.value.updateProps(attrs)
102102
}, {
103103
deep: true,
104104
})

0 commit comments

Comments
 (0)