我正在尝试将 xterm.js 库用于 Ionic 3 项目。
Github 有来源:https ://github.com/aircable/ionic-xterm和说明。它编译并启动,但没有正确显示,或者根本没有显示。布局不对。
其他问题是加载插件。其中一些尝试被注释掉了。
这是 home.ts 的摘录
import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as Terminal from "xterm";
//import style from 'xterm/dist/xterm.css';
import "xterm/dist/addons/fit/fit";
@Component({
selector: 'terminal',
templateUrl: "home.html",
//styles: [ style ]
//styleUrls: ["./xterm.css"]
})
export class HomePage implements OnInit {
private term: Terminal;
constructor( public navCtrl: NavController ) {
this.term = new Terminal( {cursorBlink: true} );
this.term.open( document.getElementById("terminal") );
//Terminal.loadAddon( "fit" );
//this.term.fit();
this.term.writeln('Welcome to xterm.js');
// this is
this.term.on('key', (key, ev) => {
console.log( key );
});
}
ngOnInit () {}
}