vue组件实现Tab切换功能
来源:互联网 发布:淘宝要怎么重新注册 编辑:程序博客网 时间:2024/05/21 12:50
方法一:
http://www.jianshu.com/p/5757e2198304
<!DOCTYPE html><html><head> <meta charset="utf-8"/> <title>Demo</title> <script src="https://cdn.bootcss.com/vue/2.4.1/vue.min.js"></script></head><body> <div id="app"> <div :is="tabShow"></div> <button @click="tab('A')">tab1</button> <button @click="tab('B')">tab2</button> <button @click="tab('C')">tab3</button> <button @click="tab('D')">tab4</button> </div> <script> A = { template:`<h1>我是第一一一个tab</h1>` } B = { template:`<h1>我是第二二二个tab</h1>` } C = { template:`<h1>我是第三三三个tab</h1>` } D = { template:`<h1>我是第四四四个tab</h1>` } new Vue({ el:'#app', data(){ return { tabShow:'A' } }, components:{ 'A': A, 'B': B, 'C': C, 'D': D }, methods:{ tab(currentShowTab){ this.tabShow = currentShowTab; } } }) </script></body></html>
方法二:
mint ui tabContainer的应用
<mt-navbar v-model="selectedVal"> <mt-tab-item id="1" @click.native.prevent="active = 'tab-container1'"> <img slot="icon" v-bind:src="wjxselIcon" v-if="addBrowseCountQues > 0" /> 问题 </mt-tab-item> <mt-tab-item id="2" @click.native.prevent="active = 'tab-container2'"> <img slot="icon" v-bind:src="wjxselIcon" v-if="addAns > 0" /> 回答 </mt-tab-item> <mt-tab-item id="3" @click.native.prevent="active = 'tab-container3'"> <img slot="icon" v-bind:src="wjxselIcon" v-if="addAtt > 0"/> 关注 </mt-tab-item> <mt-tab-item id="4" @click.native.prevent="active = 'tab-container4'"> <img slot="icon" v-bind:src="wjxselIcon" v-if="addreplyCom > 0"/> 评论 </mt-tab-item> </mt-navbar></div><!--<div :is="tabShow" @swipeVal="selected"></div>--><div class="page-tab-container" id="page-tab-container"> <mt-tab-container class="page-tabbar-tab-container" v-model="active" :swipeable="true" > <mt-tab-container-item id="tab-container1"> <myQuestions @swipeVal="selected"></myQuestions> </mt-tab-container-item> <mt-tab-container-item id="tab-container2"> <myAnswers @swipeVal="selected"></myAnswers> </mt-tab-container-item> <mt-tab-container-item id="tab-container3"> <myAttentions @swipeVal="selected"></myAttentions> </mt-tab-container-item> <mt-tab-container-item id="tab-container4"> <myComments @swipeVal="selected"></myComments> </mt-tab-container-item> </mt-tab-container></div>
iniSelecVal: function () { if (localStorage.selectedVal) { this.selectedVal = localStorage.selectedVal } else { this.selectedVal = '1' localStorage.selectedVal = '1' }},routeClick: function () { this.$router.push({'name': 'mainPage'}) localStorage.selectedVal = '1'},selected: function (res) { this.selectedVal = res},
watch: { selectedVal: function (val, oldval) { var self = this localStorage.selectedVal = val if (val === '1') { self.active = 'tab-container1' // self.tabShow = 'myQuestions' } else if (val === '2') { self.active = 'tab-container2' // self.tabShow = 'myAnswers' } else if (val === '3') { self.active = 'tab-container3' // self.tabShow = 'myAttentions' } else if (val === '4') { self.active = 'tab-container4' // self.tabShow = 'myComments' } else if (val === 'undefined') { self.active = 'tab-container1' // self.tabShow = 'myQuestions' } }}
阅读全文
0 0
- vue组件实现Tab切换功能
- Vue实现tab切换
- vue实现自动切换tab
- vue实现一个tab切换
- vue组件学习5(tab切换)
- vue实现tab切换外加样式切换
- tab切换功能——vue
- 实现tab切换的功能
- Vue Tab(component 元素)实现组件间的切换及其出现的问题
- Vue.js实现tab切换效果
- Unity3D实现Tab切换,页面切换功能
- vue tab切换
- vue tab 切换
- vue tab 切换
- vue tab切换
- Axure实现Tab选项卡切换功能
- Tab切换组件(选项卡功能)实例代码
- vue里如何实现tab类似的切换class?
- 分布式系列文章——从ACID到CAP/BASE
- 测试与开发(二)
- BZOJ 1273: [BeiJingWc2008]序列
- 【Mysql】too many connections 错误
- Tensor Flow 小试牛刀(回归模型)
- vue组件实现Tab切换功能
- Gym
- jquery之同级,父级,子级间元素的添加移除
- numpy.random.seed()方法的作用
- 看书总结
- 用Python写自己的layer
- 顺序表应用7:最大子段和之分治递归法
- 图像对比度的原理
- netty源码分析之服务端启动全