简体   繁体   English

引导按钮切换不像文档那样工作

[英]Bootstrap button toggle not working like docs

I copied below directly from the v5.1 documentation and just updated my href.我直接从 v5.1文档中复制了下面的内容,并刚刚更新了我的 href。 The link works in a dropdown I have but I want to leverage the below buttons instead.该链接在我拥有的下拉列表中有效,但我想改用下面的按钮。

    <a href="/events/?future=true" class="btn btn-primary active" role="button" data-bs-toggle="button" aria-pressed="true">Upcoming events</a>
    <a href="/events/?past=true" class="btn btn-primary" role="button" data-bs-toggle="button">Past events</a>

Below is in my boilerplate.ejs file:下面是我的boilerplate.ejs 文件:

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

Which is from the install page .这是来自安装页面

My buttons click and light up, but don't change the route.我的按钮点击并亮起,但不要更改路线。 Why isn't this working?为什么这不起作用?

it's not changing route because of the query mark you have in your url, you have:由于您在 url 中的查询标记,它不会改变路线,您有:

/events/?future=true
/events/?past=true

if you want a different route it should be a clear route, not a query.如果你想要一条不同的路线,它应该是一条清晰的路线,而不是查询。 do you have a backend server?你有后端服务器吗?

if yes I think your url must be: (in case you want to redirect)如果是,我认为您的 url 必须是:(如果您想重定向)

/events/future
/events/past

In other case, can you please provide some more information, do you have files with those names?在其他情况下,您能否提供更多信息,您有这些名称的文件吗? how do you expect those to redirect?您如何期望那些重定向? and why?为什么?

However, I'm sure your url is changing in the url browser bar whem you click either.但是,我确定您的 url 在您单击任一浏览器栏中时正在发生变化。 In short, A query doesn't redirect.简而言之,查询不会重定向。

I'm sorry I can't write a plain comment, still need few points to be able to write anywhere I'd like.对不起,我不能写一个简单的评论,仍然需要几个点才能在我想写的任何地方写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM