vue实现选项卡切换效果
效果如下:
说明:
这里我使用的原理是利用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实现选项卡切换效果的更多相关文章
- vue实现tab选项卡切换效果
tab选项卡切换效果: 通过点击事件传入参数,然后通过v-show来进行切换显示 <template> <div class="box"> <div ...
- 使用ViewPager+Fragment实现选项卡切换效果
实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动屏幕会切换Fragment并实现选项卡下方下边框条跟随移动效果. 本程序用androi ...
- 使用jquery实现选项卡切换效果
几张简陋的框架效果图 页面加载时: 选项卡操作后: css样式: <style type="text/css"> *{margin:0px;padding:0px;} ...
- 用html+css+js实现选项卡切换效果
文章转载自:http://tongling.github.io/JSCards/ 用html+css+js实现选项卡切换效果 使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材 ...
- [前端] html+css+javascript 实现选项卡切换效果
用html+css+js实现选项卡切换效果使用之前学过的综合知识,实现一个新闻门户网站上的常见选项卡效果: 文字素材:房产: 275万购昌平邻铁三居 总价20万买一居 200万内购五环三居 140万安 ...
- JS实现选项卡切换效果
1.在网页制作过程中,我们经常会用到选项卡切换效果,它能够让我们的网页在交互和布局上都能得到提升 原理:在布局好选项卡的HTML结构后,我们可以看的出来,选项卡实际上是三个选项卡标头和三个对应的版块, ...
- 纯js实现网页tab选项卡切换效果
纯js实现网页tab选项卡切换效果 百度搜索 js 点击菜单项就可以切换内容的效果
- vue实现选项卡切换--不用ui库
vue的ui库中基本都有选项卡切换的组件,但是在项目开发过程中却不一定能很好的为我们所用,因为里面的样式和 一些状态并不能很好的根据我们的项目需求进行定制.最近项目中使用的是vant-ui中的标签页, ...
- 二、JavaScript语言--JS基础--JavaScript进阶篇--选项卡切换效果
利用JavaScript知识,实现选项卡切换的效果. 效果图: 文字素材: 房产: 275万购昌平邻铁三居 总价20万买一居 200万内购五环三居 140万安家东三环 北京首现零首付楼 ...
随机推荐
- 【PBFT】拜占庭容错
共识机制堪称区块链的核心.我们知道,EOS.Hyperledger以及Stellar等著名的项目,都采用了BFT(拜占庭容错)共识机制,那么,BFT到底是什么鬼?和其它共识机制相比,又有什么优势和特点 ...
- 转载:eclipse中web项目小地球没了
转载自:{FROM:http://www.cnblogs.com/zhouyalei/archive/2013/01/30/2882651.html} MyEclipse下创建的项目 导入eclips ...
- 源码分析笔记Vector
概述 继承抽象类AbStractList,实现接口List.RandomAccess.Cloneable以及序列化接口默认容量大小为10,扩容增量为0,扩容为原容量的2倍如设置的增量大于0,则扩容为( ...
- (转)df命令
转:http://man.linuxde.net/df df命令用于显示磁盘分区上的可使用的磁盘空间.默认显示单位为KB.可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息. 语法 d ...
- springmvc知识点整理
1.Springmvc架构 2.Springmvc组件三大组件:处理器映射器,处理器适配器,视图解析器处理器映射器:注解式处理器映射器,对类中标记了@ResquestMapping的方法进行映射,根据 ...
- win10下cmd备注
要复制cmd里的字符串,右键选标记,选中待复制的字符串,ctrl+c 复制,ctrl+v粘贴内容(或者右键选择复制).这项操作支持复制cmd里的内容到其他地方,如txt里 win10之前cmd不支持c ...
- linux在二进制文件中查找pattern的offset
参考:http://stackoverflow.com/questions/14141008/grep-offset-of-ascii-string-from-binary-file strings ...
- Ascii Chart
Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex -------------------------- ...
- lerna----一个强大的专注组件库的管理工具
最近在看关于lerna的资料,没有中文版api.简书上有一篇文章半英半汉,可以撸来看看. http://www.jianshu.com/p/63ec67445b0f
- [fw]Linux 的 time 指令
Linux 的 time 指令 Linux 有個很有意思的 time 指令,可以用來查看另一個指令的執行時間,例如執行 time helloworld 會顯示 helloworld 這支程式的執行 ...