Skip to content

Commit de0d50d

Browse files
committed
docs: explain how to call the methods of svelte-jsoneditor
1 parent e337dc9 commit de0d50d

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,24 @@ Including the boolean properties of svelte-jsoneditor like `readOnly` with no va
10371037
| ---------- | ------------------- | ------ |
10381038
| jsonEditor | JSONEditor instance | object |
10391039

1040+
### Calling the methods of svelte-jsoneditor
1041+
1042+
```vue
1043+
<script setup>
1044+
import { onMounted, ref } from 'vue'
1045+
1046+
const jsonEditorVueRef = ref()
1047+
1048+
onMounted(() => {
1049+
jsonEditorVueRef.value.jsonEditor.focus()
1050+
})
1051+
</script>
1052+
1053+
<template>
1054+
<JsonEditorVue ref="jsonEditorVueRef" />
1055+
</template>
1056+
```
1057+
10401058
<br>
10411059

10421060
## Types

demo/vue3/index.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { parse, stringify } from 'lossless-json'
44
import type { Mode } from '../../src'
55
import JsonEditorVue from '../../src'
66
7-
const console = window.console
8-
97
const LosslessJSONParser = {
108
parse, /* : (json) => { return JSON.parse(json, (k, v, { source }) =>
119
(typeof source === 'number' && source > Number.MAX_SAFE_INTEGER)
@@ -43,7 +41,7 @@ const data = reactive<{
4341
4442
const jsonEditorVueRef = ref()
4543
onMounted(() => {
46-
console.log('expand: ', jsonEditorVueRef.value.jsonEditor.expand)
44+
jsonEditorVueRef.value.jsonEditor.focus()
4745
})
4846
</script>
4947

docs/README.zh-CN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,24 @@ createApp(App)
10351035
| ---------- | --------------- | ------ |
10361036
| jsonEditor | JSONEditor 实例 | object |
10371037

1038+
### 调用 svelte-jsoneditor 的方法
1039+
1040+
```vue
1041+
<script setup>
1042+
import { onMounted, ref } from 'vue'
1043+
1044+
const jsonEditorVueRef = ref()
1045+
1046+
onMounted(() => {
1047+
jsonEditorVueRef.value.jsonEditor.focus()
1048+
})
1049+
</script>
1050+
1051+
<template>
1052+
<JsonEditorVue ref="jsonEditorVueRef" />
1053+
</template>
1054+
```
1055+
10381056
<br>
10391057

10401058
## 类型

0 commit comments

Comments
 (0)