Merge pull request #833 from feizhen/editor-json-worker-fix

fix(components): 修复monaco-editor加载json worker报错问题
This commit is contained in:
liaoxuezhi 2020-08-10 15:16:30 +08:00 committed by GitHub
commit cc9fc91200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ function filterUrl(url: string) {
} }
(window as any).MonacoEnvironment = { (window as any).MonacoEnvironment = {
getWorkerUrl: function(moduleId: string, label: string) { getWorkerUrl: function (moduleId: string, label: string) {
let url = '/pkg/editor.worker.js'; let url = '/pkg/editor.worker.js';
if (label === 'json') { if (label === 'json') {
@ -202,7 +202,7 @@ export class Editor extends React.Component<EditorProps, any> {
}); });
// json 默认开启验证。 // json 默认开启验证。
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ monaco.languages.json?.jsonDefaults.setDiagnosticsOptions({
enableSchemaRequest: true, enableSchemaRequest: true,
validate: true, validate: true,
allowComments: true allowComments: true