我正在嘗試創(chuàng)建一個(gè) ace 編輯器,該編輯器在角材料中使用時(shí)會(huì)引發(fā)錯(cuò)誤ace.edit 找不到 div #javascript-editor我在這里有我的代碼StackBlitz(檢查控制臺(tái)是否有錯(cuò)誤)應(yīng)用程序組件.html<mat-tab-group> <mat-tab label="Editor"> <h4>Custom Editor</h4> <div id="javascript-editor" style="height: 300px;"></div> </mat-tab></mat-tab-group>app.component.tsimport { Component, OnInit } from '@angular/core';import * as ace from 'brace';import 'brace/mode/javascript';import 'brace/theme/monokai';@Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ]})export class AppComponent implements OnInit { ngOnInit() { const editor = ace.edit('javascript-editor'); editor.getSession().setMode('ace/mode/javascript'); editor.setTheme('ace/theme/monokai'); }}
ace.edit 在 mat-tab 中找不到 div #javascript-editor
眼眸繁星
2021-11-12 14:59:00