导航栏上的Bootstrap 4丸在点击时消失

时间:2016-12-25 22:45:44

标签: html ruby-on-rails twitter-bootstrap navbar nav

我正在尝试将bootstrap 4丸添加到导航栏中以获取rails 5应用程序以及滚动间谍。在大多数情况下,这似乎有效。然而,在第二次点击时,药片消失。例如,点击其中一个链接,比如说,工作正常,但点击第二个链接,比如功能,就会失败。

以下是导航栏的代码:

<nav class="navbar navbar-fixed-top navbar-dark bg-inverse">
  <ul class="nav navbar-nav nav-pills">
    <li class="nav-item active" role="tablist">
      <a class="nav-link" href="#one">Home <span class="sr-only">(current)</span></a>
    </li>
    <li class="nav-item" role="tablist">
      <a class="nav-link" href="#two">About</a>
    </li>
    <li class="nav-item" role="tablist">
      <a class="nav-link" href="#three">Features</a>
    </li>
    <li class="nav-item" role="tablist">
      <a class="nav-link" href="#four">Contact Us</a>
    </li>
  </ul>
</nav> 

和我的application.html.erb中的代码:

<!DOCTYPE html>
<html>
<head>
    <title>TITLE</title>
    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

<body data-spy="scroll" data-target=".navbar" data-offset="50">
    <%= yield %>
</body>
</html>

我没有任何自定义的javascript(也许这就是问题?),控制台输出没有显示任何错误(这里我启动了服务器,然后单击关于,然后单击联系我们,然后在联系人上我们点击,药片消失了):

=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.2 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/" for 127.0.0.1 at 2016-12-26 09:55:35 -0500
  ActiveRecord::SchemaMigration Load (0.2ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by WelcomeController#index as HTML
  Rendering welcome/index.html.erb within layouts/application
  Rendered welcome/index.html.erb within layouts/application (1.0ms)
Started GET "/" for 127.0.0.1 at 2016-12-26 09:55:35 -0500
Processing by WelcomeController#index as HTML
  Rendering welcome/index.html.erb within layouts/application
  Rendered welcome/index.html.erb within layouts/application (0.4ms)
Completed 200 OK in 326ms (Views: 324.8ms | ActiveRecord: 0.0ms)


Completed 200 OK in 543ms (Views: 535.1ms | ActiveRecord: 0.0ms)


Started GET "/" for 127.0.0.1 at 2016-12-26 09:55:37 -0500
Processing by WelcomeController#index as HTML
  Rendering welcome/index.html.erb within layouts/application
  Rendered welcome/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 57ms (Views: 54.7ms | ActiveRecord: 0.0ms)


Started GET "/" for 127.0.0.1 at 2016-12-26 09:55:39 -0500
Processing by WelcomeController#index as HTML
  Rendering welcome/index.html.erb within layouts/application
  Rendered welcome/index.html.erb within layouts/application (0.4ms)
Completed 200 OK in 52ms (Views: 51.2ms | ActiveRecord: 0.0ms)

编辑:在玩这个游戏时,我注意到在导航链接的第二次点击时,有一个轻微的闪烁,然后药片消失。 知道为什么会这样吗? 谢谢!

0 个答案:

没有答案