原生js\JQuery中使用前端框架的模块

在项目中使用xterm时,发现网上包括官方给出的使用方式都是Vue的那种import模块的,

import { Terminal } from 'xterm';
import { FitAddon } from 'xterm-addon-fit';

const term = new Terminal();
const fitAddon = new FitAddon();
term.loadAddon(fitAddon);

// Open the terminal in #terminal-container
term.open(document.getElementById('terminal-container'));

// Make the terminal's size and geometry fit the size of #terminal-container
fitAddon.fit();

但手头项目是原生js的,所以还是得考虑原生js使用这个模块,

经过一顿查资料和尝试,最后是这样使用的,

使用前先找到相应的js文件,再引入,

<script src="../js/xterm.js" charset="utf-8"></script>
var term = new window.Terminal();
term.fitAddon = new window.FitAddon.FitAddon();

这个尝试目前就是这样的,使用也是正常的,

猜你喜欢

转载自www.cnblogs.com/1394htw/p/13206079.html