【问题标题】:bootstrap modal does not show in basic ASP.NET Core Web angular application基本 ASP.NET Core Web Angular 应用程序中不显示引导模式
【发布时间】:2019-06-30 15:30:01
【问题描述】:

我是所有浏览器 UI 工具的新手。我一直在研究一个简单的角度/打字稿应用程序。我使用 VS2017 ASP.NET 核心 Web 应用程序模板创建了一个 Angular 应用程序。我无法显示模式窗口。

我看到几个回答说您需要包含 jquery 和/或 bootstrap.js。但我不知道在这个项目中在哪里指定这些。我使用 nuget 安装 angular、bootstrap,甚至安装了 jquery 和 jquery.ui.combined,但没有成功。

<h1>Hello, world!</h1>
<p>Welcome to your new single-page application, built with:</p>

<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

我尝试了一堆不同的示例来显示模态,但我还没有进行模态显示。

【问题讨论】:

    标签: asp.net twitter-bootstrap visual-studio-2017


    【解决方案1】:

    我可以确认这也适用于 Visual Studio 2019 Angular 模板。

    在“angular.json”中添加了提到的脚本,例如:

           "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css",
              "src/assets/fonts/fonts-fontname.css"
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
    

    谢谢托尼!

    【讨论】:

      【解决方案2】:

      我是新手,只有新手才知道。我只需要在“angular.json”中包含 jquery 和 bootstrap 脚本。我将以下内容添加到“脚本”数组中。

      "scripts": [
          "./node_modules/jquery/dist/jquery.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js"
      ]
      
      

      【讨论】:

        猜你喜欢
        • 2022-10-20
        • 2017-01-31
        • 2020-10-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多