Bootstrap 4:为什么可滚动下拉列表中的弹出窗口不显示?

Bootstrap 4: Why popover inside scrollable dropdown doesn't show?

我希望它像 Bootstrap 一样工作 3. 当我在悬停弹出窗口上有一个带滚动条的下拉菜单时,我认为 Bootstrap 有问题 4. 我需要 overflow:hidden;使下拉菜单滚动,但弹出窗口也被隐藏了。我尝试使用 container:'body' 但它没有用。

$(document).ready(function() {
  $('[data-toggle="popover"]').popover({
    html: true,
    container: 'body'
  });
});
.dropdown-menu{
 height: 150px;
 overflow: hidden;
 overflow-y: auto
}
<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap Example</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Dropdowns</h2>
                                     
  <div class="dropdown">
    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
      Dropdown button
    </button>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#" title="Header" data-toggle="popover" data-placement="right" data-trigger="hover"data-content="Some content">Link 1</a></a>
      <a class="dropdown-item" href="#" title="Header" data-toggle="popover" data-placement="right" data-trigger="hover" data-content="Some content">Link 2</a>
      <a class="dropdown-item" href="#">Link 3</a>
      <a class="dropdown-item" href="#">Link 4</a>
      <a class="dropdown-item" href="#">Link 5</a>
      <a class="dropdown-item" href="#">Link 6</a>
      <a class="dropdown-item" href="#">Link 7</a>
      <a class="dropdown-item" href="#">Link 8</a>
      <a class="dropdown-item" href="#">Link 9</a>
    </div>
  </div>
</div>

有一些 issues 带有 popper.js,以及它如何定位下拉菜单、弹出窗口和工具提示。解决方案是将弹出窗口上的 data-boundary 选项设置为 window...

Demo on Codeply

$(document).ready(function() {
  $('[data-toggle="popover"]').popover({
  });
});
.dropdown-menu{
 height: 150px;
 overflow: hidden;
 overflow-y: auto
}
<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap Example</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
  <h2>Dropdowns</h2>
  <div class="dropdown">
    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
      Dropdown button
    </button>
    <div class="dropdown-menu">
      <a class="dropdown-item" href="#" title="Header" data-boundary="window" data-toggle="popover" data-placement="right" data-trigger="hover"data-content="Some content">Link 1</a></a>
      <a class="dropdown-item" href="#" title="Header" data-boundary="window" data-toggle="popover" data-placement="right" data-trigger="hover" data-content="Some content">Link 2</a>
      <a class="dropdown-item" href="#">Link 3</a>
      <a class="dropdown-item" href="#">Link 4</a>
      <a class="dropdown-item" href="#">Link 5</a>
      <a class="dropdown-item" href="#">Link 6</a>
      <a class="dropdown-item" href="#">Link 7</a>
      <a class="dropdown-item" href="#">Link 8</a>
      <a class="dropdown-item" href="#">Link 9</a>
    </div>
  </div>
</div>