简体   繁体   English

标签中的Vue.js链接

[英]Vue.js link in a tag

How do I link properly to another page with vue 2 ? 如何使用vue 2正确链接到另一个页面? I have a bootstrap table and every row has to link somewhere else how could I do this? 我有一个引导表,每一行都必须链接到其他地方,我该怎么做? If I do it like this: 如果我这样做:

<tr @click="url(forum)">data</tr>

url(forum) {
  window.location.href = '/berichten/' + forum.slug;    
}

I can't add another @click in that row like this: 我不能在该行中添加另一个@click ,如下所示:

<td @click="destroy(forum)">forum</td>

NOTE: I do not use Vue.js router. 注意:我不使用Vue.js路由器。

Any help would be much appreciated 任何帮助将非常感激

--EDIT-- - 编辑 -

When I click on the <td @click="destroy(forum)"> it goes to the url(forum); 当我点击<td @click="destroy(forum)">它会转到url(forum); function instead of my destroy(forum) function. 函数而不是我的destroy(forum)函数。

Prevent event propagation on your nested click handler by using the ".stop" modifier : 使用“ .stop” 修饰符可防止事件在嵌套点击处理程序上传播:

<td @click.stop="destroy(forum)">forum</td>

Demo (non-Vue.js): 演示(non-Vue.js):

https://jsfiddle.net/atesgoral/xgn92eb0/ https://jsfiddle.net/atesgoral/xgn92eb0/

Try modifying your td click declaration to have .stop so that the click event isn't bubbled up to the tr 尝试将您的td click声明修改为具有.stop ,以使click事件不会冒泡到tr

It would look like this: 它看起来像这样:

<td @click.stop="destroy(forum)">forum</td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM