0

我正在尝试在我的网络应用程序中使用 Xterm fit 插件,但我无法加载它。xtermjs 高度默认为 408px。我希望它适合它的容器元素。但是每当我尝试加载它时,我都会收到错误消息。

文档指示通过 导入它import { FitAddon } from 'xterm-addon-fit';,但我需要通过<script>标签导入它

<script>问题是:导入插件vis标签时如何使用fit插件?

提前致谢

var term = new Terminal({
    cursorBlink: true, 
    scrollback: 10000,
    theme: {
        background: '#1c1b18'
    },
});

//term.loadAddon(FitAddon)
                 term.open(document.getElementById('terminal'));
                 
term.writeln('test');
html, body {
    height: 100%;
}

#terminal-container{
    height: 100%;
}
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@4.11.0/css/xterm.css"/>
<script src="https://cdn.jsdelivr.net/npm/xterm@4.11.0/lib/xterm.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-attach@0.6.0/lib/xterm-addon-attach.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.5.0/lib/xterm-addon-fit.js"></script>
</head>

<body>
  <div id="terminal-container">
      <div id="terminal"></div>
  </div>
</body>

4

0 回答 0