vue3引入json-editor-vue3问题

模版使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//模板使用
<json-editor-vue class="editor" v-model="data" />

// 组件内引用
import JsonEditorVue from 'json-editor-vue3'

export default {
name: 'app',
components: {
JsonEditorVue
},
data() {
return {
data: {
"hello": "vue"
}
}
},
methods: {}
}

引用完之后有报错

SyntaxError: The requested module ‘/node_modules/jsoneditor/dist/jsoneditor.min.js?v=00499bcc’ does not provide an export named ‘default’ (at json-editor.vue:2:8)

解决方案

1
2
3
4
5
6
7
8
9
10
1.
// 组件内引用
import 'jsoneditor'
import JsonEditorVue from 'json-editor-vue3'

2.
// 根目录创建 declaration.d.ts 文件
// 文件内容如下:
declare module 'json-editor-vue3'


vue3引入json-editor-vue3问题
https://zhaops-hub.github.io/2025/11/13/js/vue3引入json-editor-vue3问题/
作者
赵培胜
发布于
2025年11月13日
许可协议