vue 点击获取元素的css属性

1、首先要获取背点击的元素

通过点击事件event,event.target 既被点击的元素

javascript 复制代码
// param为别的参数
<button @click="(event) => {handler(event,param)}"><i class="el-icon-close "></i></span>
// 不传参数,默认参数为event
<button @click="handler"><i class="el-icon-close "></i></span>

// 获取当前点击的元素
        event.target 
// 获取触发绑定事件的元素
        event.currentTarget 
// 获取当前点击的元素的父元素
        event.currentTarget.parentElement
//
handler(event,index) {
      // 获取css属性对象 window.getComputedStyle(event.currentTarget)
      if(window.getComputedStyle(event.currentTarget).opacity == '1'){
                // todo 
            }
        },

2、 window.getComputedStyle 获取元素的css属性对象

相关推荐
半兽先生15 分钟前
告别 AI 乱写 Vue!用 vue-skills 构建前端智能编码标准
前端·vue.js·人工智能
前端达人43 分钟前
都2026年了,还在用Options API?Vue组合式API才是你该掌握的“正确姿势“
前端·javascript·vue.js·前端框架·ecmascript
Dxy12393102161 小时前
Python检查JSON格式错误的多种方法
前端·python·json
chao-Cyril2 小时前
从入门到进阶:前端开发的成长之路与实战感悟
前端·javascript·vue.js
shalou29012 小时前
Spring 核心技术解析【纯干货版】- Ⅶ:Spring 切面编程模块 Spring-Instrument 模块精讲
前端·数据库·spring
大时光2 小时前
js 封装 动画效果
前端
大时光2 小时前
html翻页时钟 效果
前端
大猫子的技术日记2 小时前
2025 AI Agent 开发实战指南:从上下文工程到多智能体协作
前端·人工智能·bootstrap
前端达人2 小时前
被JavaScript忽视的Web Animations API:为什么说它是前端动画的真正未来?
开发语言·前端·javascript·ecmascript
忧郁的橙子.2 小时前
04-从零搭建本地AI对话系统:Ollama + DeepSeek-R1:7B + Streamlit
前端·chrome