vue + xterm 前端终端terminal
引入
import {Terminal} from "xterm";
import {FitAddon} from "xterm-addon-fit";
import "xterm/css/xterm.css";
html
<div id="terminal"></div>
vue
onMounted(() => {
nextTick(() => {
initTerm();
})
})
const initTerm = async () => {
let termContainer = document.getElementById("terminal");
term = new Terminal({
lineHeight: 1.3,
fontSize: 15,
fontFamily:
"WenQuanYi Micro Hei, Monaco, Menlo, Consolas, 'Courier New', monospace",
theme: {
background: '#181d28',
},
unicodeVersion: 12,
convertEol: true,
// 光标闪烁
cursorBlink: true,
cursorStyle: 'underline',
scrollback: 100,
tabStopWidth: 4,
});
term.open(termContainer)
};
write
命令 | 含义 |
---|---|
term.write(‘\n’) | 换行 |
term.write(‘\r’+内容) | 从头替换当前行内容 |
write(‘\x1b[2K\r’) | 删除当前整行 |
调整光标位置
term._core.buffer.x = 0;
原文地址:https://blog.csdn.net/weixin_39423672/article/details/140654169
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!