javascript - Bootstrap 5 Popover 错误 - 找不到名称“bootstrap”
问题描述
我正在尝试在我的 Angular 12 项目的 Javascript 中创建一个弹出框。我正在使用 Boostrap v5.0.1
。当我尝试创建弹出框时,我似乎无法摆脱名称错误:
var exampleEl = document.getElementById(item.name + index);
var tooltip = new bootstrap.Popover(exampleEl, {
container: 'body',
animation: true
});
打字稿告诉我"Can't find name bootstrap"
。
我已将 bootrap.js 添加到我的 angular.json 文件中:
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
根据文档,popper.js 包含在捆绑文件中。我没有使用 jQuery,也不想包含它。我还没有看到另一篇有类似问题的帖子,所以我一定只是忽略了一些小事。有任何想法吗?
解决方案
在文件顶部发布此声明有效:
declare var bootstrap: any;
推荐阅读
- mongodb - MongoDB 3.6 中的日期范围查询
- javascript - 我想从 HTML 表中创建一个 JSON 对象。我希望最终产品用于统计来自多个用户的输入
- python - tfidf w2v 给出 NaN 值
- node.js - 针对特定操作系统执行 node.js API
- apache-spark - 在 Spark 2.3 中给出 Maven 依赖错误
- user-interface - Flutter如何在滚动到某个点后仍然存在的列表视图中添加按钮..
- sql-server - 是否可以在 Azure VM 上安装 SSMS 并连接到 Azure SQL 数据库
- android - 用于 Android 的 Cordova 中的 XMLHttpRequest
- java - Android 创建自定义操作栏 3 项
- reactjs - 在 react-google-maps 中设置 OverlayView 的 z-index