首页 > 解决方案 > 使用路由处理单击另一个组件内的组件?

问题描述

我的模板中有这种结构

<div to="/route/route1">
     <i class="material-icons">airplay</i>
      <span>Title</span>
      <custom-button @click.native="doSomething"></custom-button>
</div>

通过单击自定义按钮,我想调用此方法并导航到另一条路线

doSomething() {
     this.$router.push({path: 'route/route2'});
  }

现在,当我单击自定义按钮时,我仍然会去route1

有没有办法用这种结构来完成这项工作?

标签: vue.js

解决方案


推荐阅读