Bootstrap 5 模态未显示

问题描述 投票:0回答:1

我已将 Bootstrap 5 作为 Nuget 包包含在内,并尝试在页面上设置模式。 Bootstrap 5 的其他方面正在按预期工作。

  <div class="col-12">
  <button type="button" class="btn entry-button" data-bs-toggle="modal" data-bs-target="#logInModal">Log In</button>
  <div class="modal" id="logInModal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          It works
        </div>
        <div class="modal-body">
          It works
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
  <button type="button" class="btn entry-button">Create Account</button>
</div>

我正在一个带有 ASP.NET 后端的 Angular 项目中执行此操作。

编辑:该按钮在窗口中显示正常,我可以单击它,并且控制台中没有发生错误。

我还没有使用过“index.html”文件。就是这个:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>ActreelClient</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
</body>
</html>

所有其他引导功能都工作正常。

angular bootstrap-modal bootstrap-5
1个回答
0
投票

安装引导程序和@types/boostrap

npm i bootstrap
npm i @types/boostrap

更改 angular.json 以包含 bootstrap.css 和 bootstrap.bundle.min.js

"scripts": ["node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"],
"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.css",
              "src/global_styles.css"],

只需复制 bootstrap 中的示例即可

注意:在这个 stackblitz 中,如果您想要一些灵感,我会使用最流行的引导组件。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.