小编Ala*_*lak的帖子

如何在react.js组件中使用Bootstrap 5 Popover?

我在 React 中使用 CDN 的 Bootstrap 5。我有一个组件将在反应组件之一中使用 Popover。因此,根据文档,它说“您必须在 bootstrap.js 之前包含 popper.min.js 或使用包含 Popper 的 bootstrap.bundle.min.js / bootstrap.bundle.js 才能使弹出窗口正常工作!”

并且要初始化页面上的所有弹出窗口,请使用给定的 javascript 代码:

var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-
toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  return new bootstrap.Popover(popoverTriggerEl)
})
Run Code Online (Sandbox Code Playgroud)

但我无法在我的反应组件中的 useEffect 中使用它,因为它返回“bootstrap.Popover(popoverTriggerEl)”对象,该对象在我的反应组件中未定义。

请问有人可以指导我吗?

dom reactjs react-bootstrap virtual-dom bootstrap-5

2
推荐指数
1
解决办法
4371
查看次数

标签 统计

bootstrap-5 ×1

dom ×1

react-bootstrap ×1

reactjs ×1

virtual-dom ×1