Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 未找到模块:错误:Can';t解决';ace/编辑会话';_Angular_Ace Editor - Fatal编程技术网

Angular 未找到模块:错误:Can';t解决';ace/编辑会话';

Angular 未找到模块:错误:Can';t解决';ace/编辑会话';,angular,ace-editor,Angular,Ace Editor,我在我的angular项目中嵌入了ace编辑器。但在我的ts文件中,它总是告诉ace/edit_会话模块未找到。我已将require包含在tsconfig中 我的ts文件: import { Component, OnInit } from '@angular/core'; declare var ace : any; @Component({ selector: 'app-editor', templateUrl: './editor.component.html', styl

我在我的angular项目中嵌入了ace编辑器。但在我的ts文件中,它总是告诉ace/edit_会话模块未找到。我已将require包含在tsconfig中

我的ts文件:

import { Component, OnInit } from '@angular/core';

declare var ace : any;

@Component({
  selector: 'app-editor',
  templateUrl: './editor.component.html',
  styleUrls: ['./editor.component.css']
})
export class EditorComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/twilight");
    var EditSession = require("ace/edit_session").EditSession;
    var js = new EditSession("some js code");
    var css = new EditSession(["some", "css", "code here"]);
    editor.session.setMode("ace/mode/python");
    editor.setOptions({
      'fontSize': 17,
      'behavioursEnabled': true,
      'wrapBehavioursEnabled': false,
      'wrap': true,
      'indentedSoftWrap': false,
      'enableLiveAutocompletion': true,
   });

// and then to load document into editor, just call
editor.setSession(js);

  }

}

答案取决于您在页面中包含ace的方式,这在上面的代码段中没有显示


但是由于
ace.edit
已经适合您,而不是
require(“ace/edit_session”).EditSession
尝试使用ace.EditSession或ace.require(“ace/edit_session”),这应该出现在最新版本的ace上。

答案取决于您在页面中包含ace的方式,而这在上面的代码段中没有显示


但是由于
ace.edit
已经适合您,而不是
require(“ace/edit_session”).EditSession
尝试使用ace.EditSession或ace.require(“ace/edit_session”),这应该出现在最新版本的ace上。

您可以尝试使用源文件ace js作为脚本包含在index.htm中

例如,角度的另一种方式:

1) 使用npm或纱线安装“ace构建”

npm i ace-builds
2) 将ace导入组件

3) 在组件中初始化编辑器

4) 内部HTML页面:

<div id="editor"></div>

通过将源文件ace js作为脚本包含在index.htm中,可以尝试使用not

例如,角度的另一种方式:

1) 使用npm或纱线安装“ace构建”

npm i ace-builds
2) 将ace导入组件

3) 在组件中初始化编辑器

4) 内部HTML页面:

<div id="editor"></div>

尝试将ace声明为var ace=require('ace')尝试将ace声明为var ace=require('ace')我已将ace js源文件作为脚本包含在index.html中我已将ace js源文件作为脚本包含在index.html中