效果如下:

说明:

这里我使用的原理是利用vue中的v-show/显示隐藏指令,当为true的时候显示,为false的时候隐藏

1html代码:

<head>
<meta charset="UTF-8">
<base target="_blank">
<title>vue实现选项卡切换效果</title>
<script src="js/jquery-1.8.2.min.js"></script>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<!--主体内容-->
<div class="center">
<!--Tap选项卡部分-->
<div class="center-left-tap">
<a href="javascript:void (0)" style="color: #1c1c1c;" class="current" @click="mt1">最新</a>
<a href="javascript:void (0)" class="a-hover" @click="mt2">B2C</a>
<a href="javascript:void (0)" class="a-hover" @click="mt3">C2C</a>
<a href="javascript:void (0)" class="a-hover" @click="mt4">传统零售</a>
<a href="javascript:void (0)" class="a-hover" @click="mt5">其他</a>
</div>
<div class="container" id="container01">
<!--第一个 最新-->
<div v-for="val in xuan" v-show="a">
<div class="con" style="">
<div class="center-left-body bg">
<div class="img-box1">
<img :src="val.img1" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">{{val.h1}}</a></p>
<p><a href="detail-1.html" class="center-left-body-a2">{{val.p1}}</a></p>
<p class="mb-p">{{val.math}}</p>
<img :src="val.img2" alt="" class="mb-img">
<p><a href="" class="tab-mt">{{val.a1}}</a><a href="" class="tab-mt">{{val.a2}}</a></p>
</div>
</div>
</div>
<!--第二个 B2C-->
<div class="con" v-show="b">
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181112_1542008037535.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181112_1541985913463.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div> </div>
<!--第三个 C2C-->
<div class="con" v-show="c">
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181107_1541569944473.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181107_1541569944473.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181112_1542010837701.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div> </div>
<!--第四个 传统零售-->
<div class="con" v-show="d">
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181113_1542076349985.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181113_1542075324144.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181112_1542027463929.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181107_1541569944473.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="" class="tab-mt">企业服务</a><a href="" class="tab-mt">投融资</a></p>
</div> </div>
<!--第五个 其他-->
<div class="con" v-show="e">
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181113_1542091666106.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="detail-1.html" class="tab-mt">企业服务</a><a href="detail-1.html" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181113_1542091506167.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="detail-1.html" class="tab-mt">企业服务</a><a href="detail-1.html" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181113_1542089470929.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="detail-1.html" class="tab-mt">企业服务</a><a href="detail-1.html" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181107_1541569944473.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="detail-1.html" class="tab-mt">企业服务</a><a href="detail-1.html" class="tab-mt">投融资</a></p>
</div>
<div class="center-left-body bg">
<div class="img-box1">
<img src="img-index/20181112_1542008037535.jpg" alt="" class="img-h b-img">
</div>
<p><a href="detail-1.html" class="center-left-body-a1">夫妻店再升级 20万小店接入零售通参加双11</a></p>
<p><a href="detail-1.html"
class="center-left-body-a2">据了解,天猫双十一期间,除20万家街边小店外,还有3000家天猫小店也将参与到线下活动中。</a></p>
<p class="mb-p">2018-11-10 16:32</p>
<img src="img-2/ico_pindao_dingyue.png" alt="" class="mb-img">
<p><a href="detail-1.html" class="tab-mt">企业服务</a><a href="detail-1.html" class="tab-mt">投融资</a></p>
</div> </div>
</div>
</div>
</div><!--vue 结束-->
</body>

2css代码:

<style>
.center{width: 1160px;margin: 0 auto;}
a{text-decoration: none;color: #595959;}
a:hover{color: #1a79ff;}
/*tap选项卡*/
.center-left-tap{height: 58px;}
.center-left-tap a{font-size: 16px;color: #999;margin-right: 37px;padding-bottom: 19px;}
.a-hover:hover{color: #595959;} /*图文重复内容*/
.center-left-body{width: 820px;height: 127px;border-top:1px solid #ddd;margin-top: -15px;padding: 21px 0;margin-bottom: 20px;}
.center-left-body img:nth-child(1){width: 190px;height: 127px;float: left;}
.center-left-body-a1{float: left;margin-left: 20px;font-size: 18px;line-height: 26px;color: #333;margin-top: -175px;}
.center-left-body-a2{float: left;margin-left: 210px;font-size: 16px;color: #595959;margin-top: -95px;word-wrap:break-word;}
.mb-p{float: left;margin-top: -20px;margin-left: 210px;color:#999;}
.mb-img{float: left;margin-top: -20px;margin-left: 15px;}
.tab-mt{margin-right: -30px;margin-left: 50px;margin-top: -20px;float: left;}
.bor-no{border: none;}
.bg:hover{background-color:#efefef;}
</style>

3js:

<script>
var vm = new Vue({
el: '#app',
data: {
xuan: [],
a: true,
b: false,
c: false,
d: false,
e: false,
},
mounted: function () {
this.getData()
},
methods: {
getData() {
$.ajax({
type: 'get',
url: 'frame-1.json',
detaType: 'JSON',
success: function (data) {
vm.xuan = data.xuan
}
})
}, // 选项卡
mt1: function () {
this.a = true
this.b = false
this.c = false
this.d = false
this.e = false
},
mt2: function () {
this.a = false
this.b = true
this.c = false
this.d = false
this.e = false
},
mt3: function () {
this.a = false
this.b = false
this.c = true
this.d = false
this.e = false
},
mt4: function () {
this.a = false
this.b = false
this.c = false
this.d = true
this.e = false
},
mt5: function () {
this.a = false
this.b = false
this.c = false
this.d = false
this.e = true
}
}
});
</script>

应届菜鸟,大佬勿喷...

vue实现选项卡切换效果的更多相关文章

  1. vue实现tab选项卡切换效果

    tab选项卡切换效果: 通过点击事件传入参数,然后通过v-show来进行切换显示 <template> <div class="box"> <div ...

  2. 使用ViewPager+Fragment实现选项卡切换效果

    实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果. 本程序用androi ...

  3. 使用jquery实现选项卡切换效果

    几张简陋的框架效果图 页面加载时: 选项卡操作后: css样式: <style type="text/css"> *{margin:0px;padding:0px;} ...

  4. 用html+css+js实现选项卡切换效果

    文章转载自:http://tongling.github.io/JSCards/ 用html+css+js实现选项卡切换效果 使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材 ...

  5. [前端] html+css+javascript 实现选项卡切换效果

    用html+css+js实现选项卡切换效果使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材:房产: 275万购昌平邻铁三居 总价20万买一居 200万内购五环三居 140万安 ...

  6. JS实现选项卡切换效果

    1.在网页制作过程中,我们经常会用到选项卡切换效果,它能够让我们的网页在交互和布局上都能得到提升 原理:在布局好选项卡的HTML结构后,我们可以看的出来,选项卡实际上是三个选项卡标头和三个对应的版块, ...

  7. 纯js实现网页tab选项卡切换效果

    纯js实现网页tab选项卡切换效果 百度搜索     js 点击菜单项就可以切换内容的效果

  8. vue实现选项卡切换--不用ui库

    vue的ui库中基本都有选项卡切换的组件,但是在项目开发过程中却不一定能很好的为我们所用,因为里面的样式和 一些状态并不能很好的根据我们的项目需求进行定制.最近项目中使用的是vant-ui中的标签页, ...

  9. 二、JavaScript语言--JS基础--JavaScript进阶篇--选项卡切换效果

    利用JavaScript知识,实现选项卡切换的效果. 效果图: 文字素材: 房产: 275万购昌平邻铁三居 总价20万买一居     200万内购五环三居 140万安家东三环     北京首现零首付楼 ...

随机推荐

  1. Windows系统启动iis方法详解

    很多网友一般都用Windows 系统自带的iis服务器来配置web网站,在本地进行调试和修改后才正式上线.虽说操作不难,但是小白来说却无从下手,很多人根本不知道iss在哪,怎么启动,更谈不上配置或者其 ...

  2. C#将Json字符串转化为对象

    实体类: public class CheckData { public string msg; public string code; public string data; public stri ...

  3. soj#551 loj#2833 帐篷

    传送门 分析 dp[i][j]表示考虑了i行j列的方案数 我们每次考虑三种情况: 一个点自己放 两个点在同一行 两个点在同一列 代码 #include<bits/stdc++.h> usi ...

  4. Windows-计划任务-自动备份数据库和文件

    开始 -> 程序 -> 附件 -> 系统工具 -> 计划任务 .bat 文件如下: ::数据库+文件备份 @echo off ::日期时间 set yyyymmdd=%date ...

  5. HttpServletRequest 对文件上传的支持

    此前,对于处理上传文件的操作一直是让开发者头疼的问题,因为 Servlet 本身没有对此提供直接的支持,需要使用第三方框架来实现,而且使用起来也不够简单.Servlet 3.0 已经提供了这个功能,而 ...

  6. electron测试TCP通信

    这几天学习了一下Elctron,对于这个应用有了一点简单的认识,将这个过程记录一下. 首先,electron会加载main.js,在这里将整个程序启动,相当于其他程序的main函数了. 我是基于ele ...

  7. python 类和对象下

    类的常用函数 issubclass() 检测一个类是否是另外一个类的子类 格式1:issubclass(被检测类,父类) 返回值:布尔值 格式1:issubclass(被检测类,(父类1,父类2,父类 ...

  8. oracle使用时间戳

    TO_DATE ( '2019-12-05 00:00:00', 'yyyy-mm-dd hh24:mi:ss' ) AS UPDATE_DATE,

  9. spring cloud学习--eureka 01

    本博客为学习使用,学习教程翟永超 spring cloud 微服务实战 搭建eureka server注册中心 spring initialize构建spring boot项目 构建网址:https: ...

  10. 【转】Pandas速查手册中文版

    本文翻译自文章:Pandas Cheat Sheet - Python for Data Science,同时添加了部分注解. 对于数据科学家,无论是数据分析还是数据挖掘来说,Pandas是一个非常重 ...