我正在为我的应用程序尝试bootstrap vue选项卡。我想禁用所有选项卡点击,但希望使用导航按钮浏览选项卡。
但是当我试图增加标签索引时,它会再次自动设置为零。
是否有任何方法可以禁用标签点击,但可以通过上一个和下一个按钮进行导航。
new Vue({
el: '#app',
data: {
tabIndex:0
}
})
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<script src="https://unpkg.com/vue"></script>
<script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
<div id="app">
<b-card no-body >
<b-tabs warning pills card vertical v-model="tabIndex" class="generictab" ref="wizard">
<b-tab title="Tab Contents 1">
<b-row>
<b-col sm="12">
<b-form-group>
<label for="name">Name</label>
<b-form-input type="text" id="name" placeholder="Enter your name"></b-form-input>
</b-form-group>
</b-col>
</b-row>
</b-tab>
<b-tab title="Tab Contents 2" :disabled="!(tabIndex==2)">
Tab Contents 2
</b-tab>
<b-tab title="Tab Contents 3" :disabled="!(tabIndex==3)">
Tab Contents 3
</b-tab>
</b-tabs>
<div class="text-center">
<b-button-group class="mt-2">
<b-btn @click="tabIndex--">Previous</b-btn>
<b-btn @click="tabIndex++">Next</b-btn>
</b-button-group>
<br>
<span class="text-muted">Current Tab: {{tabIndex}}</span>
</div>
</b-card>
</div>
答案 0 :(得分:2)
根据我的理解,您希望通过单击next和prev按钮进行导航,而不是单击选项卡名称。这是工作示例。希望它有所帮助。
new Vue({
el: '#app',
data: {
tabIndex:0
}
})
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<script src="https://unpkg.com/vue"></script>
<script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
<style>
.disabledTab{
pointer-events: none;
}
</style>
<div id="app">
<b-card no-body >
<b-tabs warning pills card vertical v-model="tabIndex" class="generictab" ref="wizard">
<b-tab title="Tab Contents 1" title-item-class="disabledTab">
<b-row>
<b-col sm="12">
<b-form-group>
<label for="name">Name</label>
<b-form-input type="text" id="name" placeholder="Enter your name"></b-form-input>
</b-form-group>
</b-col>
</b-row>
</b-tab>
<b-tab title="Tab Contents 2" title-item-class="disabledTab">
Tab Contents 2
</b-tab>
<b-tab title="Tab Contents 3" title-item-class="disabledTab">
Tab Contents 3
</b-tab>
</b-tabs>
<div class="text-center">
<b-button-group class="mt-2">
<b-btn @click="tabIndex--">Previous</b-btn>
<b-btn @click="tabIndex++">Next</b-btn>
</b-button-group>
<br>
<span class="text-muted">Current Tab: {{tabIndex}}</span>
</div>
</b-card>
</div>