vuejs如何拥有许多< a> <路由器ltink> gt; gt;或@Click函数
我想拥有一张明信片,例如Twitter Post Card,如果单击任何内容明信片的一部分转到发布页面,但是当单击标签或链接时,将转到
下面的标签或链接示例 1。
<div @click="gotoPostPage" class="text-weight-light text-justify">
{{ feed.content }}
<a href="https://google.com">check google</a> if you need more information then follow @benny(a tag) or follow these hashtags
#google #finda, #checks, now when i click within this post take me to post page
</div>
点击了链接
现在,即使使用此链接或标签也 2。
<router-link :to="`/post/${ feed.id }`">
{{ feed.content }}
<a href="https://google.com">check google</a> if you need more information then follow @benny(a tag) or follow
these hashtags
#google #finda, #checks, now when i click within this post take me to post page
</router-link>
即使检查google 请点击
请如何解决这个问题,您的帮助非常感谢,非常感谢您的帮助, 谢谢
i want to have a post card like twitter post card, if clicked on any part of the post card goes to post page, but when clicked on hashtags or links goes to the hashtag or link
example below
1.
<div @click="gotoPostPage" class="text-weight-light text-justify">
{{ feed.content }}
<a href="https://google.com">check google</a> if you need more information then follow @benny(a tag) or follow these hashtags
#google #finda, #checks, now when i click within this post take me to post page
</div>
now this hits the gotoPostPage function even if link or a tag is clicked
using this also
2.
<router-link :to="`/post/${ feed.id }`">
{{ feed.content }}
<a href="https://google.com">check google</a> if you need more information then follow @benny(a tag) or follow
these hashtags
#google #finda, #checks, now when i click within this post take me to post page
</router-link>
goes to even when check google is clicked
Please how can i resolve this, your help is highly appreciated,
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
@单击
添加到您的链接。例如:这将停止
的传播>单击
事件到父元素元素。注意:
@click.stop
是@conce@click =“ e =&gt; e.stoppropagation()”
。在这里。
更新,根据注释中显示的数据:
我将避免存储HTML ID数据库。那是一个非常糟糕的模式。您应该从UI层分离数据。您必须允许根据设备和介质更改UI层。我会尝试将该数据存储为
String
s保存标签名称,而该名称与Hastag不同,如在对象上,都包含两个。这样的事情:
如您所见,它从数据中产生HTML。该模板还应用
stopPropagation()
,在v-for
中。Add
@click.stop
to your links. E.g:This will stop propagation of
click
events to the parent DOM elements.Note:
@click.stop
is shorthand for@click="e => e.stopPropagation()"
.Docs here.
Update, based on data shown in comment:
I would avoid storing HTML id database. That's a really bad pattern. You're supposed to detach the data from the UI layer. You have to allow the UI layer to change, based on device and medium. I'd try to store that data as
string
s holding a hashtag name and, where the name is different than the hastag, as on object, containing both.Something like this:
As you can see, it produces the HTML from the data. The template also applies the
stopPropagation()
, in thev-for
.