无法创建摩纳哥编辑器

时间:2019-03-07 21:52:44

标签: angular angular7 monaco-editor

尝试从https://github.com/Microsoft/monaco-editor创建monaco编辑器时 我得到了this.model.onDidChangeRawContentFast不是一个函数

ERROR Error: Uncaught (in promise): TypeError: 

this.model.onDidChangeRawContentFast is not a function
TypeError: this.model.onDidChangeRawContentFast is not a function
    at ViewModel.push../node_modules/monaco-editor/esm/vs/editor/common/viewModel/viewModelImpl.js.ViewModel._registerModelEvents (viewModelImpl.js:141)
    at new ViewModel (viewModelImpl.js:68)
    at StandaloneEditor.push../node_modules/monaco-editor/esm/vs/editor/browser/widget/codeEditorWidget.js.CodeEditorWidget._attachModel (codeEditorWidget.js:939)
    at StandaloneEditor.push../node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneCodeEditor.js.StandaloneEditor._attachModel (standaloneCodeEditor.js:198)
    at new StandaloneEditor (standaloneCodeEditor.js:180)
    at standaloneEditor.js:57
    at withAllStandaloneServices (standaloneEditor.js:44)
    at Object.create (standaloneEditor.js:56)
    at MonacoComponent.<anonymous> (monaco.component.ts:167)
    at step (tslib.es6.js:97)
    at resolvePromise (zone.js:831)
    at new ZoneAwarePromise (zone.js:913)
    at Module.__awaiter (tslib.es6.js:67)
    at MonacoComponent.push../Source/app/shared/components/monaco/monaco.component.ts.MonacoComponent._createEditor (monaco.component.ts:158)
    at MonacoComponent.push../Source/app/shared/components/monaco/monaco.component.ts.MonacoComponent.ngAfterViewInit (monaco.component.ts:102)
    at callProviderLifecycles (core.js:22406)
    at callElementProvidersLifecycles (core.js:22380)
    at callLifecycleHooksChildrenFirst (core.js:22370)
    at checkAndUpdateView (core.js:23306)
    at callViewAction (core.js:23538)

这是在7号角上

import * as monaco from 'monaco-editor';
monaco.editor.create(this.editorContainer.nativeElement);

我是通过esm aka npm install monaco-editor安装的,package.json看起来正确。有没有人遇到这个错误?

1 个答案:

答案 0 :(得分:0)

我已修复它,我通过CDN安装了旧版本,并且那里存在一些冲突。删除旧软件包完全消除了错误:)