当前位置:网站首页>【SDU项目实训2019级】router-link的:to 和@click谁先执行
【SDU项目实训2019级】router-link的:to 和@click谁先执行
2022-06-09 06:40:00 【李小恩恩子】
在写下面的代码的时候:
<div class="section-title">
<router-link tag="a" :to="{path: '/contentAll',query:{id:tableData.contentId}}" @click="postRecord(tableData.contentId)" class="sTitle-sub-head" style="font-size: 18px;color: #606060">—展开—</router-link>
</div>由于点击这个router-link会触发两个不同的事件,一个是href属性所对应的链接,一个是@click,然后我发现,我每次点击,并不会触发我的@click里面调用的js函数,搜了一下,然后发现:
原因:router-link会阻止click,mouseover事件,只用click不用native,事件不会触发。
根据Vue2.0官方文档关于父子组件通讯的原则,父组件通过prop传递数据给子组件,子组件触发事件给父组件。但父组件想在子组件上监听自己的click的话,需要加上native修饰符。(转发的router-link 点击事件 - 掘金 (juejin.cn))
然后将@click事件加上了native:
<div class="section-title">
<router-link tag="a" :to="{path: '/contentAll',query:{id:tableData.contentId}}" @click.native="postRecord(tableData.contentId)" class="sTitle-sub-head" style="font-size: 18px;color: #606060">—展开—</router-link>
</div>能在跳转前执行@click对应的js函数了。然后将该数据向后端发送request请求,存到数据库。
边栏推荐
- Can I use machine learning programming without knowing mathematics?
- YOLOv4解析 | 第二篇:用YOLOv4训练自己的数据集(超级详细完整版)
- Mendeley and other document management tools to insert references in word
- make install 安装的库,如何卸载
- BSP tailoring of Quanzhi platform (3) Appendix II: description of kernel hacking configuration
- Chapter_ 03 mask operation of matrix
- Fastadmin custom exported excl table name + time
- Pour un ingénieur logiciel expérimenté, qu'est - ce qui aurait pu être un nouveau langage de programmation préféré pour l'apprentissage?
- Chapter_05 使用Opencv相加(融合)两个图像
- Do you really understand entropy (including cross entropy)
猜你喜欢

Qt--- create dialog box 1: implementation of the subclass search keyword dialog box of qdialog

Quanzhi v3s learning record -- use of esp8089

Codeblocks项目窗口管理

Chapter_ 01 mat: basic image container

Intranet control: nodemcu (esp8266) and Arduino serial port communication

CodeBlocks老是重复运行上一次结果

fastadmin 自定义导出的excl表名称+时间

Avez - vous vraiment compris l'entropie (y compris l'entropie croisée)

UML系列文章(22)高级行为---状态机

Chapter_02 如何扫描查看图像,查询表以及Opencv中的时间度量
随机推荐
Allocate stall principle of ZGC
自己写的小工具,pillow库将图片转为buf
BSP tailoring of Quanzhi platform (7) rootfs tailoring -- tailoring of user tools and Libraries & rootfs compression
Comparison between ZGC and G1 and the meaning of color points
[raspberry pie 4B deep learning Yolo] Chap.1 configure a Yolo model for raspberry pie (Darknet nnpack) [deep learning moves]
你真的懂熵了吗(含交叉熵)
For an experienced software engineer, what would be a preferred new programming language to learn?
make install 安装的库,如何卸载
多线程并发-私有构造函数捕获模式
Svn account password search
Multithreading Basics (II)
戒烟日志_02 (day_06)
Chapter_ 04 image operation
量化交易之MySql篇 - mysql数据库 增删改查
error: subprocess-exited-with-error(fasttext)
Batch writing tidb to improve writing efficiency
For an experienced software engineer, what would be a preferred new programming language to learn?
二叉树的递归套路
批量写入tidb提高写入效率
Can I use machine learning programming without knowing mathematics?