我一直试图将用户重定向到与使用Laravel和Bootstrap v4时相同的选项卡。
例如,如果用户从“治疗”标签创建治疗,我希望他被重定向回同一标签,即“治疗”
请在下面找到我用于标签导航的代码。
<div class="card ">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs pull-right" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="treatments-tab" data-toggle="tab" href="#treatments" role="tab" aria-controls="treatments" aria-selected="true"><i class="fas fa-tooth fa-fw"></i> Dental Treatments</a>
</li>
<li class="nav-item">
<a class="nav-link" id="companies-tab" data-toggle="tab" href="#companies" role="tab" aria-controls="companies" aria-selected="false"><i class="fas fa-building fa-fw"></i> Insurance Companies</a>
</li>
</ul>
</div>
<div class="card-body">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="treatments" role="tabpanel" aria-labelledby="treatments-tab">...</div>
<div class="tab-pane fade" id="companies" role="tabpanel" aria-labelledby="companies-tab">...</div>
</div>
</div>
</div>
我试图遵循这两种方法,但都没有奏效。
https://medium.com/@grmcameron/redirect-to-a-specific-tab-in-laravel-149398a9e655
Redirect back to a specific tab pane in Laravel
试图将包含特定单词的消息从控制器发送到刀片,但它也无法正常工作。
能否请您说明如何实现?
谢谢, 杰克
答案 0 :(得分:0)
您只需要提供每个标签的id属性即可。每次都调用url中特定标签的ID。例如url#companies
@PostMapping("/deleteArticle")
@CrossOrigin(origins = "http://localhost:4200")
public String deleteArticle(@RequestParam() Article article,
RedirectAttributes redirectAttributes) {
deleteService.deleteArticle(article.id, redirectAttributes);
}