基于xterm.js 实现Vue版本终端terminal
先看效果
image
前端实现
xterm
npm install --save xterm
xterm-addon-fit
xterm.js的插件,使终端的尺寸适合包含元素。
npm install --save xterm-addon-fit
xterm-addon-attach
xterm.js的附加组件,用于附加到Web Socket
npm install --save xterm-addon-attach
import 'xterm/css/xterm.css'
import { Terminal } from 'xterm'
import { FitAddon } from 'xterm-addon-fit'
import { AttachAddon } from 'xterm-addon-attach'
export default {
name: 'Xterm',
props: {
socketURI: {
type: String,
default: ''
},
},
mounted() {
this.initSocket()
},
beforeDestroy() {
this.socket.close()
this.