twitter-bootstrap Bootstrap 4 标签没有切换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42147974/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap 4 Tabs are not switching
提问by Ace
I am currently using bootstrap 4. I read the bootstrap documentation and am currently trying to incorporate tabs but they are not switching my code is the following:
我目前正在使用 bootstrap 4。我阅读了 bootstrap 文档,目前正在尝试合并选项卡,但他们没有切换我的代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Info</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0- alpha.3/css/bootstrap.min.css" integrity="sha384-MIwDKRSSImVFAZCVLtU0LMDdON6KVCrZHyVQQj6e8wIEJkW4tvwqXrbMIya1vriY" crossorigin="anonymous">
</head>
<body>
<?php include_once("template_pageTop.php"); ?>
<div class="container p-t-md">
<div class="row">
<div class="col-md-6">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#currentPreferences">Current Preferences</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#alternative"> Alternative </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="currentPreferences">
<ul class="list-group media-list media-list-stream">
<?php
display();
?>
</ul>
</div>
<div role="tabpanel" class="tab-pane fade in" id="alternative">
<ul class="list-group media-list media-list-stream">
<p>Test</p>
</ul>
</div>
</div>
</div>
</div>
</div>
<?php include_once("template_pageBottom.php"); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"> </script>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>
</html>
I have added the javascript libraries but it does not seem to be switching is there anything else I can add? Any feedback is welcomed. Thank you
我已经添加了 javascript 库,但它似乎没有切换,还有什么我可以添加的吗?欢迎任何反馈。谢谢
回答by Zim
You need to use data-toggle="tab"data attribute in each link, or initialize using JavaScript..
您需要data-toggle="tab"在每个链接中使用data 属性,或者使用 JavaScript 初始化..
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#currentPreferences">Current Preferences</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#alternative"> Alternative </a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#">Link</a>
</li>
</ul>

