[英]How to use router-link with event?
I want to pass the information to another page.When I was just testing without using route I was able to pass information from one component to anther but when I implemented route like this, It navigating to other component when click event I am not getting information to another page.我想将信息传递到另一个页面。当我只是在不使用路由的情况下进行测试时,我能够将信息从一个组件传递到另一个组件,但是当我实现这样的路由时,它在单击事件时导航到其他组件我没有得到信息到另一页。 The code is below which has a issue, sorry I cannot post all of the code because of code is too lengthy.
下面的代码有问题,抱歉,由于代码太长,我无法发布所有代码。 Can anyone help me please?
有人可以帮我吗?
<router-link @click.native="$emit('viewDetails', model)" to="/modelDetails">
view details
</router-link>
If you want both the emission and the navigation to occur, you probably want to use a regular <a>
and bind it to a method on the component that handles both of these actions:如果您希望发射和导航都发生,您可能希望使用常规
<a>
并将其绑定到组件上处理这两个操作的方法:
<a @click="myFunc(model)">View details</a>
methods: {
myFunc(model) {
this.$emit('viewDetails', model);
this.$router.push('/modelDetails');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.