demo

<template>
<div id="app" class="app-box">Hello</div>
</template> <script>
import {
Terminal
} from 'xterm'
import 'xterm/dist/xterm.css'
export default {
name: 'app',
mounted() {
let term = new Terminal({
rendererType: "canvas", //渲染类型
rows: 40, //行数
convertEol: true, //启用时,光标将设置为下一行的开头
scrollback:10,//终端中的回滚量
disableStdin: false, //是否应禁用输入。
cursorStyle: 'underline', //光标样式
cursorBlink: true, //光标闪烁
theme: {
foreground: 'yellow', //字体
background: '#060101', //背景色
cursor: 'help',//设置光标
}
})
term.open(document.getElementById('app')) term.writeln(`✔ Installed 1 packages
✔ Linked 0 latest versions
✔ Run 0 scripts
Recently updated (since 2019-05-10): 1 packages (detail see file
/Users/baolilei/Desktop/project/felab/xterm.js/fe-source-stage/src/xterm/node_modules/.recently_updates.txt)
Today:
→ xterm@*(3.13.1) (01:15:03)
✔ All packages installed (1 packages installed from npm registry, used 1s(network 1s), speed 365.87kB/s, json
1(7.12kB), tarball 509.49kB)`) function runFakeTerminal() {
if (term._initialized) {
return;
} term._initialized = true; term.prompt = () => {
term.write('\r\n$ ');
}; term.writeln('Welcome to xterm.js');
term.writeln('This is a local terminal emulation, without a real terminal in the back-end.');
term.writeln('Type some keys and commands to play around.');
term.writeln('');
term.prompt(); term.on('key', function (key, ev) {
const printable = !ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey;
console.log(key,ev.keyCode);
console.log(term._core.buffer.x); if (ev.keyCode === 13) {
term.prompt();
} else if (ev.keyCode === 8) {
// Do not delete the prompt
if (term._core.buffer.x > 2) {
term.write('\b \b');
}
} else if (printable) {
term.write(key);
}
}); term.on('paste', function (data) {
term.write(data);
});
}
runFakeTerminal();
} } </script> <style lang="scss">
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
</style>

  参考资料:

- [xterm的配置](https://github.com/xtermjs/xterm.js/blob/3.12.0/typings/xterm.d.ts#L16)
 

最新文章

  1. Caused by: java.lang.UnsatisfiedLinkError: Couldn&#39;t load BaiduMapVOS_v2_1_3: findLibrary returned nu
  2. iOS和Android测试区别
  3. static关键字总结
  4. CSS+JS实现兼容性很好的无限级下拉菜单
  5. windows下,python+scrapy环境搭建
  6. C语言/C++中怎样产生随机数
  7. PHP 返回近7天 本月 上月日期
  8. The server does not support version 3.1 of the JEE Web module specification.
  9. Android 连接 SQL Server (jtds方式)——上
  10. 工具使用 eclipse the user operation is waiting for Building Working to be completed。
  11. 【QT相关】对话框相关
  12. greenlet 详解
  13. Service详解
  14. 39. leetcode 326. Power of Three
  15. Linux下SVN安装配置以及使用
  16. Amazon email system中使用的字体
  17. Mysql 快速指南
  18. JavaSE面试题收集【仅有题目,答案自备】
  19. redis在linux云服务器上完整的搭建步骤
  20. VS2017做为Unity3D的脚本编辑器需要的最精简组件

热门文章

  1. 攻防世界--simple-unpack
  2. hadoop工作流调度系统
  3. elasticsearch 基础 —— Delete By Query API
  4. xcode 5.0 连接svn error -(NSURLErrorDomain error -1012)
  5. MySQL01---简介及安装
  6. Codecraft-17 and Codeforces Round #391 - B
  7. 左上角小猫猫直达博主GitHub \-_-/
  8. Navicat Premium 12 如何连接阿里云虚拟主机SQL Server 数据库
  9. tomcat启动一闪而过处理
  10. APIO2019 练习赛 Wedding cake——思路+高精度