我正在尝试在我的 Angular 12 项目的 Javascript 中创建一个弹出窗口。我正在使用 Boostrap v5.0.1
。当我尝试创建弹出窗口时,我似乎无法摆脱名称错误:
var exampleEl = document.getElementById(item.name + index);
var tooltip = new bootstrap.Popover(exampleEl, {
container: 'body',
animation: true
});
Typescript 告诉我 “找不到名称 Bootstrap ”
。
我已将 bootrap.js 添加到我的 angular.json 文件中:
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
根据文档,popper.js 包含在捆绑文件中。我没有使用 jQuery,也不想包含它。我还没有看到另一篇有类似问题的帖子,所以我一定是忽略了一些小问题。有什么想法吗?
最佳答案
在文件顶部发布此声明有效:
declare var bootstrap: any;
关于javascript - Bootstrap 5 Popover 错误 - 找不到名称 'bootstrap',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68216663/