<template>
<div>
<div class="navbox">
<div class="nav" id="navbox">
<mt-button size="small" v-for="(tab, i) in tabs" :class="{active01:tab.hasactive}" @click="forChageTag(i)" @click.native.prevent="active = tab.container">{{tab.title}}</mt-button>
<!--<mt-button size="small" @click.native.prevent="active = 'tab-container2'">tab 2</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container3'">tab 3</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container4'">tab 4</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container5'">tab 5</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container6'">tab 6</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container7'">tab 7</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container8'">tab 8</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container9'">tab 9</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container10'">tab 10</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container11'">tab 11</mt-button>
<mt-button size="small" @click.native.prevent="active = 'tab-container12'">tab 12</mt-button>-->
</div>
</div>
<div class="page-tab-container">
<mt-tab-container class="page-tabbar-tab-container" v-model="active" swipeable>
<mt-tab-container-item id="tab-container1">
<!-- cell组件 -->
<mt-cell v-for="n in 20" title="tab-container 1"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container2">
<!-- cell组件 -->
<mt-cell v-for="n in 5" title="tab-container 2"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container3">
<!-- cell组件 -->
<mt-cell v-for="n in 7" title="tab-container 3"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container4">
<!-- cell组件 -->
<mt-cell v-for="n in 10" title="tab-container 4"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container5">
<!-- cell组件 -->
<mt-cell v-for="n in 5" title="tab-container 5"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container6">
<!-- cell组件 -->
<mt-cell v-for="n in 7" title="tab-container 6"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container7">
<!-- cell组件 -->
<mt-cell v-for="n in 10" title="tab-container 7"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container8">
<!-- cell组件 -->
<mt-cell v-for="n in 5" title="tab-container 8"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container9">
<!-- cell组件 -->
<mt-cell v-for="n in 7" title="tab-container 9"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container10">
<!-- cell组件 -->
<mt-cell v-for="n in 10" title="tab-container 10"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container11">
<!-- cell组件 -->
<mt-cell v-for="n in 5" title="tab-container 11"></mt-cell>
</mt-tab-container-item>

<mt-tab-container-item id="tab-container12">
<!-- cell组件 -->
<mt-cell v-for="n in 7" title="tab-container 12"></mt-cell>
</mt-tab-container-item>
</mt-tab-container>
</div>
</div>
</template>

<script>
export default {
name: 'page-tab-container',
data() {
return {
active: 'tab-container1',
marginLeft: 0,
tabs: [{
title: '推荐',
container: 'tab-container1',
hasactive: true
}, {
title: '美文',
container: 'tab-container2',
hasactive: false
}, {
title: '健康',
container: 'tab-container3',
hasactive: false
}, {
title: '资讯',
container: 'tab-container4',
hasactive: false
}, {
title: '娱乐',
container: 'tab-container5',
hasactive: false
}, {
title: '搞笑',
container: 'tab-container6',
hasactive: false
}, {
title: '美图',
container: 'tab-container7',
hasactive: false
}, {
title: '美食',
container: 'tab-container8',
hasactive: false
}, {
title: '科技',
container: 'tab-container9',
hasactive: false
}, {
title: '文化',
container: 'tab-container10',
hasactive: false
}, {
title: '历史',
container: 'tab-container11',
hasactive: false
}, {
title: '财经',
container: 'tab-container12',
hasactive: false
}
]};
},
methods:{
forChageTag (index){
console.log(index);
console.log(this.tabs.length);
var tablen = this.tabs.length;
for(var n = 0;n < tablen; n++){
if(n == index){
this.tabs[index].hasactive = true;
console.log(document.querySelector('#navbox'));
}else{
this.tabs[n].hasactive = false;
}
}
}
},
watch:{
active:function (newValue) {
// active即为mt-tab-container的参数,这里监听它的改变并可以做相关操作:
// 在你的tabBar组件点击的时候更改active的值
// 滑动mt-tab-container-item组件即更改active的值,监听newValue的变化并操作你的tabBar,使得点击切换和滑动切换相关联
console.log(newValue);
var tabarr = newValue.replace("tab-container", "");
console.log(tabarr);
var tabIndex = parseInt(tabarr)-1;
console.log(tabIndex);
var tablen = this.tabs.length;
for(var n = 0;n < tablen; n++){
if(n == tabIndex){
this.tabs[tabIndex].hasactive = true;
}else{
this.tabs[n].hasactive = false;
}
}
}
}
};
</script>
<style lang="stylus" scoped>
.item
display: inline-block
.navbox
position: fixed
left: 0
top: 0
z-index: 20
width: 100%
overflow-x: scroll
overflow-y: hidden
background-color: #fff
.nav
padding: 0 10px
width: 1285px
position: relative
background-color: #f6f8fa
box-shadow: 0 0 1px #b8bbbf
.mint-button--small
margin: 0 25px
padding: 0
.mint-button--default
color: #656b79
background-color: #f6f8fa
box-shadow: none
.mint-button
border-radius: 0
.active01
color: #f00
border-bottom: 4px solid #f00

.navbox::-webkit-scrollbar
display: none

</style>

vue2.0+mint-ui 仿资讯类顶导航内容联动优化的更多相关文章

  1. vue2.0+mint-ui资讯类顶导航和内容页联动实例(不是很完美)

    <template> <div> <div class="navbox"> <div class="nav"> ...

  2. vue2.0 + Element UI + axios实现表格分页

    注:本文分页组件用原生 html + css 实现,element-ui里有专门的分页组件可以不用自己写,详情见另一篇博客:https://www.cnblogs.com/zdd2017/p/1115 ...

  3. vue2.0 + element ui 实现表格穿梭框

    element ui 官网里介绍了穿梭框(Transfer),但在实际使用过程中,会出现一些问题: 1.穿梭框里能放置的内容太少,不能满足复杂的业务需求. 2.当选项过多时,穿梭框很难实现分页,左右两 ...

  4. vue2.0+Element UI 表格前端分页和后端分页

    之前写过一篇博客,当时对element ui框架还不太了解,分页组件用 html + css 自己写的,比较麻烦,而且只提到了后端分页 (见 https://www.cnblogs.com/zdd20 ...

  5. vue2.0+Element UI 实现动态表单(点击按钮增删一排输入框)

    对于动态增减表单项,Element UI 官方文档表单那一节已经介绍得很清楚了,我之前没有看见,绕了很多弯路,这里针对点击按钮增删一排输入框的问题做一个总结. 效果图如下 存在一排必填的姓名与手机号, ...

  6. vue 专题 vue2.0各大前端移动端ui框架组件展示

    Vue 专题 一个数据驱动的组件,为现代化的 Web 界面而生.具有可扩展的数据绑定机制,原生对象即模型,简洁明了的 API 组件化 UI 构建 多个轻量库搭配使用 请访问链接: https://ww ...

  7. 项目vue2.0仿外卖APP(四)

    组件拆分 先把项目搭建时生成的代码给清了吧 现在static目录下引入reset.css 接着在index.html引入,并且设置<meta> 有时候呢,为了让代码符合我们平时的编码习惯, ...

  8. iOS开发之资讯类App常用分类控件的封装与实现(CollectionView+Swift3.0+)

    今天博客中,我们就来实现一下一些常用资讯类App中常用的分类选择的控件的封装.本篇博客中没有使用到什么新的技术点,如果非得说用到了什么新的技术点的话,那么勉强的说,用到了一些iOS9以后UIColle ...

  9. 【饿了么】—— Vue2.0高仿饿了么核心模块&移动端Web App项目爬坑(三)

    前言:接着上一篇项目总结,这一篇是学习过程记录的最后一篇,这里会梳理:评论组件.商家组件.优化.打包.相关资料链接.项目github地址:https://github.com/66Web/ljq_el ...

随机推荐

  1. 虚拟机 VMware Workstation Pro 15.5.0 及永久激活密钥

    虚拟机 VMware Workstation Pro 15.5.0 及永久激活密钥 虚拟机下载地址:https://download3.vmware.com/software/wkst/file/VM ...

  2. 【Linux常见命令】mkdir命令

    mkdir - make directories 例子: mkdir /data 在根目录/下创建data文件夹(目录) 语法: mkdir [-p] dirName 参数说明: -p 确保目录名称存 ...

  3. 【Linux常见问题】CentOS 6 root用户密码忘记,找回密码方法

    1.Linux的root密码修改不像Windows的密码修改找回,Windows的登录密码忘记需要介入工具进行解决.CentOS6和CentOS7的密码方法也是不一样的,具体如下: 2.centos ...

  4. 标准库hashlib模块

    hashlib模块用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512, MD5 算法(都是基于hash的算法, ...

  5. javascript SDK开发之webpack中eslint的配置

    eslint的好处就不多说了.代码检查,代码报错, 智能提示,让开发人员更规范的撸代码等等. 1.安装依赖 npm install --save-dev eslint eslint-friendly- ...

  6. usermod,用户密码管理,mkpasswd命令

    passwd是更改用户密码的文件,如果在root下,我们可以直接输入这个命令更改密码[root@localhost ~]# passwd更改用户 root 的密码 .新的 密码:如果想更改其他用户的密 ...

  7. centos6 yum安装jdk1.8+

    一.环境Linux操作系统: centos6.9 安装jdk版本: jdk1.8+ 二.安装步骤1. 检查系统是否自带有jdk[root@VM_0_11_centos ~]# rpm -qa |gre ...

  8. bat 命令

    1.强制杀死进程 /F force 强制性/IM image + 进程名 TASKKILL /F /IM python.exe

  9. 从零搭建分布式文件系统MinIO比FastDFS要更合适

    前两天跟大家分享了一篇关于如何利用FastDFS组件来自建分布式文件系统的文章,有兴趣的朋友可以阅读下<用asp.net core结合fastdfs打造分布式文件存储系统>.通过留言发现大 ...

  10. C++中const的特性

    目录(作用): 1:修饰变量,说明该变量不可以被改变: 2:修饰指针,分为只想常量的指针和自身是常量的指针 3:修饰引用,指向常量的引用,用于修饰形参,即避免了拷贝,有避免了函数对值的修改: 4:修改 ...