我正在使用.net构建一个typescript模块,并得到一个错误。我想从Typescript使用Bootstrap并通过NPM安装它。
我有这样的东西:
import {Modal} from 'bootstrap';
function showModal(id: string) {
const el = document.getElementById(id);
let modal = Modal.getInstance(el);
if (modal == null) {
modal = new Modal(el);
}
modal.show();
}
字符串
然而,当我编译这段代码时,我得到了多个错误:
dropdown.d.ts(1, 25): [TS2792] Build:Cannot find module '@popperjs/core'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
tooltip.d.ts(1, 25): [TS2792] Build:Cannot find module '@popperjs/core'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
型
我尝试通过npm install @popperjs/core
安装丢失的模块,并包括通过:
import "@popperjs/core"
import {Modal} from 'bootstrap';
...
型
但这也不起作用。
如何在我的typescript文件中使用bootstrap?
1条答案
按热度按时间dly7yett1#
安装
字符串
然后在TS文件中包含:
型
您可能还需要安装jquery(但首先尝试不安装):
型