vue footer点击变色
2024-09-30 22:57:47
<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>
最新文章
- 来说说SpringMVC + JSONP的跨域请求
- windows cmd command line 命令
- 【Qt】Qt之自定义搜索框【转】
- Android开发(21)--有关Spinner控件的使用说明
- zf-关于SYS_User表type的分类
- node.js 下依赖Express 实现post 4种方式提交参数
- px转vw和vh的工具(对前端同学有用)
- 正则表达式——Java程序员懂你
- Nginx 单个进程允许的最大连接数
- BZOJ 1195: [HNOI2006]最短母串
- 大数乘法java版
- wget命令【转】
- Qt5中运行后台网络读取线程与主UI线程互交
- Dropdown.js基于jQuery开发的轻量级下拉框插件
- eclipse debug Liunx服务器上的svn项目
- 安装node
- 深入浅出down_interruptible
- Thread pools &; Executors
- 2019.1.4 SSH框架整合步骤(一)
- 使用Gulp实现网页自动刷新:gulp-connect
热门文章
- 解决码云未配置公钥问题——fatal: Could not read from remote repository.
- 73. PrintStream(打印流)
- loadrunner——win7+LR11配置
- Robot Framework:数据库操作
- PHP ftp_close() 函数
- homebrew -- mac os 系统下的 apt-get、yum
- hihoCoder [Offer收割]编程练习赛3 D子矩阵求和
- eclipse中server name选项变灰
- Vue中时间的设置
- Spring Boot主要目标