<header class="tab_nav">
<div v-for="(item,index) in tabNav" @click="selected(index1,$event)" :key="index1" :class="{'active':item.active}">
<img :src="item.imgUrl" alt="" >
<span>{{item.title}}</span>
</div>
</header>
1
//data内的数据
tabNav:[
{title:'我参与的',active:true,imgUrl:'/src/images/index/participate.png'},
{title:'我发布的',active:false,imgUrl:'/src/images/index/publish.png'},
{title:'我抽奖的',active:false,imgUrl:'/src/images/index/luck_draw.png'}
],
 //methods方法  tabNav栏切换导航
selected: function(index){
this.tabNav.forEach(ele => ele.active = false );
this.tabNav[index1].active = true;
// this.getActivityList();
},


 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>vue</title>
<style>
.active {
color: red;
}
</style>
</head>
<body>
<div id="example">
<ul >
<li v-for="(item, index) in navLists" :class="{active:changeRed == index}" @click="colorChange(index)">{{item.text}}</li>
</ul>
</div>
<!-- 开发环境版本,包含了用帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">
var vm = new Vue({
el: '#example',
data: {
isActive: false,
navLists: [
{
"text":"首页"
},
{
"text":"组件"
},
{
"text":"API"
},
{
"text":"我们"
}
],
changeRed : 0
},
methods: {
colorChange: function(index) {
console.log(index)
this.changeRed = index;
}
} })
</script>
</body>
</html>

最新文章

  1. 来说说SpringMVC + JSONP的跨域请求
  2. windows cmd command line 命令
  3. 【Qt】Qt之自定义搜索框【转】
  4. Android开发(21)--有关Spinner控件的使用说明
  5. zf-关于SYS_User表type的分类
  6. node.js 下依赖Express 实现post 4种方式提交参数
  7. px转vw和vh的工具(对前端同学有用)
  8. 正则表达式——Java程序员懂你
  9. Nginx 单个进程允许的最大连接数
  10. BZOJ 1195: [HNOI2006]最短母串
  11. 大数乘法java版
  12. wget命令【转】
  13. Qt5中运行后台网络读取线程与主UI线程互交
  14. Dropdown.js基于jQuery开发的轻量级下拉框插件
  15. eclipse debug Liunx服务器上的svn项目
  16. 安装node
  17. 深入浅出down_interruptible
  18. Thread pools &amp; Executors
  19. 2019.1.4 SSH框架整合步骤(一)
  20. 使用Gulp实现网页自动刷新:gulp-connect

热门文章

  1. 解决码云未配置公钥问题——fatal: Could not read from remote repository.
  2. 73. PrintStream(打印流)
  3. loadrunner——win7+LR11配置
  4. Robot Framework:数据库操作
  5. PHP ftp_close() 函数
  6. homebrew -- mac os 系统下的 apt-get、yum
  7. hihoCoder [Offer收割]编程练习赛3 D子矩阵求和
  8. eclipse中server name选项变灰
  9. Vue中时间的设置
  10. Spring Boot主要目标