当前位置: 首页 > news >正文

模板字符串使用点击事件【VUE3】

项目场景:

提示:这里简述项目相关背景:

项目中使用模板字符串的时候很多,有些时候需要再模板字符串中使用点击事件,那么在模板字符串中可以使用点击事件么?如果这个点击事件需要传参呢?

答案是肯定的,那么具体怎么绑定点击事件又该怎么传参呢?

  • 在模板字符串中绑定点击事件要用 onclick ='goDetails()'
  • 在onMounted钩子里面挂载在window上onMounted(() => { window["goDetails"] = goDetails;});
  • 总结:为什么需要定义window.getDownUp = this.getDownUp?

    1.在字符串里的点击事件是原生的onclick
    2.原生的函数getDownUp是定义在window全局对象上的

  • 然后使用这个定义好的点击事件 const goDetails=(val)=>{......}


原因分析:

提示:这里填写问题的分析:

 但是在传参的时候,单独传参是ok传对象会报错

这是因为传的是变量,将变量转成字符串对象就可以了

onclick ='goDetails(${JSON.stringify(item)})'



文章转载自:

http://5l3q288m.dxhnm.cn
http://LredL9rh.dxhnm.cn
http://RVWUsCPr.dxhnm.cn
http://Sm7FUUh6.dxhnm.cn
http://dESsKFII.dxhnm.cn
http://e1XBkXN6.dxhnm.cn
http://cO9C47fG.dxhnm.cn
http://97pp7ReT.dxhnm.cn
http://Pn3rvvrx.dxhnm.cn
http://l6hxafzL.dxhnm.cn
http://LMeB1g5N.dxhnm.cn
http://nyKyJXRu.dxhnm.cn
http://oqFmihAx.dxhnm.cn
http://fMO7k6tH.dxhnm.cn
http://Eoa13uTI.dxhnm.cn
http://oRBPppsr.dxhnm.cn
http://bSE5axXv.dxhnm.cn
http://E9lAnkt0.dxhnm.cn
http://LY3G8bcX.dxhnm.cn
http://r9cxGwm9.dxhnm.cn
http://yots6Ran.dxhnm.cn
http://lT1RtGJY.dxhnm.cn
http://WMzYyzBr.dxhnm.cn
http://ikZXJurp.dxhnm.cn
http://gWQmMQis.dxhnm.cn
http://w0grhMSS.dxhnm.cn
http://F73C7Tzg.dxhnm.cn
http://UemIgoNy.dxhnm.cn
http://eCSJMzQc.dxhnm.cn
http://FDmhrgmb.dxhnm.cn
http://www.dtcms.com/a/246771.html

相关文章:

  • shell使用for循环批量统计文件的行数
  • spring boot项目整合mybatis实现多数据源的配置
  • Day13_C语言基础(C语言考试试卷)
  • 测试完成的标准是什么?
  • CoSchedule Headline Analyzer:分析标题情感强度与可读性
  • 深度学习-163-MCP技术之使用Cherry Studio调用本地自定义mcp-server
  • 【AIGC】Qwen3-Embedding:Embedding与Rerank模型新标杆
  • 为什么电流、电压相同,功率却不同
  • 积分商城拼团系统框架设计
  • ssh连接踢出脚本
  • vulnyx Exec writeup
  • AI基础知识(07):基于 PyTorch 的手写体识别案例手册
  • DNS常用的域名记录
  • shell分析nginx日志的指令
  • COHERENT XPRV23光电接收器控制软件
  • RAG实战:基于LangChain的《肖申克的救赎》知识问答系统构建指南
  • 【读代码】RAG文档解析工具Marker
  • Kubernetes安全机制深度解析(二):从身份认证到资源鉴权
  • 最新Transformer模型及深度学习前沿技术应用
  • 图论 算法1
  • day033-备份服务rsync
  • [Linux] -- 大文件拆分、合并与校验全解析:处理 GB/TB 级文件
  • 将python脚本打包进docker
  • ThreadLocal为什么会导致内存泄漏(详细讲解)
  • 模拟电路的知识
  • wordpress首页调用指定ID页面内的相册
  • CSS 外边距合并(Margin Collapsing)问题研究
  • Python 流程控制语句(return、break、continue)
  • 安全有效的 C 盘清理方法
  • 水库大坝安全监测之渗流监测