我是 Angular 的新手。 我正在尝试使用 xterm.js ( https://xtermjs.org/ ) 但它显示不佳。 这是渲染: Render
我创建了一个 xterm 组件。 xterm.component.ts 文件代码为:
import { Component, OnInit } from '@angular/core';
import { Terminal } from "xterm";
@Component({
selector: 'app-xterm',
templateUrl: './xterm.component.html',
styleUrls: ['./xterm.component.css'],
})
export class XtermComponent implements OnInit {
public term: Terminal;
container: HTMLElement;
constructor() { }
ngOnInit() {
this.term = new Terminal();
this.container = document.getElementById('terminal');
this.term.open(this.container);
this.term.writeln('Welcome to xterm.js');
}
}
我的 xterm.component.html 只包含这个:
<div id="terminal"></div>
我真的不知道该怎么办了... 提前谢谢大家
最佳答案
必须设置组件封装
@Component({
encapsulation: ViewEncapsulation.None,
...
})
关于javascript - 将 xterm.js 集成到 Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53307998/