mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-19 04:01:33 +08:00
fix(editor): code-editor组件json类型序列化出错
This commit is contained in:
parent
5b3c700f00
commit
2d4a6aa22a
@ -37,10 +37,14 @@ const emit = defineEmits(['initd', 'save']);
|
||||
const toString = (v: string | any, language: string): string => {
|
||||
let value = '';
|
||||
if (typeof v !== 'string') {
|
||||
if (props.language.toLocaleLowerCase() === 'json') {
|
||||
value = JSON.stringify(v, null, 2);
|
||||
} else {
|
||||
value = serialize(v, {
|
||||
space: 2,
|
||||
unsafe: true,
|
||||
}).replace(/"(\w+)":\s/g, '$1: ');
|
||||
}
|
||||
} else {
|
||||
value = v;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user