vue点击变色
<template>
<div>
<router-link to="/w1">点击回去</router-link> <div v-for="(x,index) in list" v-bind:class="{red:isred===index}" @click="change(index)">
{{x.id}}-{{x.title}}-{{x.author}}
</div>
</div>
</template> <script>
export default {
name: 'News',
data () {
return {
list:[{id:1,title:"娱乐新闻",author:"小李"},
{id:2,title:"军事新闻",author:"小王"},
{id:3,title:"财经新闻",author:"小张"},],
isred:-1
}
},
methods: {
change:function(index){
this.isred=index
}
}
}
</script> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.red{
background-color: red;
}
</style>
vue点击变色的更多相关文章
- vue点击元素变色兄弟元素不变色
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- android 自定义控件——(五)按钮点击变色
----------------------------------按钮点击变色(源代码下有属性解释)------------------------------------------------- ...
- vue 点击当前元素添加class 去掉兄弟的class 获取当前点击元素的文字
点击当前标签给其添加class,兄弟标签class删除 然后获取当前点击元素的文字 演示地址: https://xibushijie.github.io/static/addClass.html &l ...
- (网页)angular中实现li或者某个元素点击变色的两种方法(转)
转自脚本之家: 本篇文章主要介绍了angular中实现li或者某个元素点击变色的两种方法,非常具有实用价值,需要的朋友可以参考下 本文介绍了angular中实现li或者某个元素点击变色的两种方法,分享 ...
- vue点击返回顶部插件vue-totop
vue-totop vue 点击返回顶部插件,可以根据参数设定按钮大小,颜色,类型,返回顶部的时间等.github地址:https://github.com/1006008051/vue-totop, ...
- vue点击切换颜色限制个数(用了mui框架)
vue点击切换颜色 只能点击一个 <!doctype html> <head> <meta charset="UTF-8"> <title ...
- vue 点击当前元素添加class 去掉兄弟的class
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- jquery 与javascript关系 ①取元素 ②操作内容 ③操作属性 ④操作 样式 ⑤ 事件 点击变色
jQuery的min版本和原版功能是一样的,min版主要应用于已经开发成的网页中,而非min版 的文件比较大,里面有整洁的代码书写规范和注释,主要应用于脚本开发过程当中. JQuery是继protot ...
- Android实现按钮点击效果(第一次点击变色,第二次恢复)
1.首先创建一个按钮 <Button android:id="@+id/click" android:layout_width="fill_parent" ...
随机推荐
- SwiftUI中多设备运行方法
https://blog.csdn.net/weixin_42679753/article/details/94465674 https://www.jianshu.com/p/17fc7929fcb ...
- Unity 打开其他exe文件
using UnityEngine; using System.Collections; using System.Diagnostics;///// public class FeiYuZhu : ...
- 八数码问题 IDA*搜索
#include<iostream> #include<string> #include<cmath> #include<cstring> #inclu ...
- 一个web项目中web.xml<context-param>的作用
转 <context-param>的作用:web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置 ...
- 四十二、在SAP中添加单选框
一.上代码 二.上文本替换截图 三.上效果图
- 168-PHP 输出系统当前时间
<body style="font-family:'华文彩云'; color:#0000CC; font-size:20px"> 系统的当前时间是: <?php ...
- 156-PHP strrpos和strripos函数
<?php //定义两个字符串 $str='pasSword'; $position=strrpos($str,'s'); //不区分大小写判断 echo "字母S在{$str}中最后 ...
- 072-PHP数组的交集和差集
<?php $arr1=array(1,3,4,5,34,78,99); //参加第一项竞赛的学生学号数组 $arr2=array(5,6,7,3,56,34,8,9); //参加第二项竞赛的学 ...
- benchmark与gem5-gpu交互
gem5-gpu作为一个异构多核系统的模拟器,当我们使用异构融合多核处理器架构(特别是支持HSA的处理器架构)运行GPU与CPU的benchmark时,研究自己设计的算法或添加的硬件对GPU与CPU存 ...
- vue学习(四)插槽
一 匿名插槽 // 语法 Vue.component('MBtn', { template: ` <button> <slot></slot> </butto ...