页面跳转--编程式导航

其实就是点击某一个元素,激发事件,使用方法进行跳转。这里记录一种最常用的方法。
需要注意的是:this.$router.push中,是router,不是routes,有时候vscode提示错误就会搞错。

<template>
  <div>
    <h3>Home页面</h3>
    <button @click="goPerson()"> 跳转到个人信息页</button>
  </div>
</template>

<script>
// @ is an alias to /src
export default {
      
      
  name: 'HomeView',
  components: {
      
      
    
  },
  methods:{
      
      
    goPerson(){
      
      
      this.$router.push({
      
      
        path: "/user/小李四/66999669"
      })
    }
  }
}
</script>

在这里插入图片描述
在这里插入图片描述
还可以发现,跳转过来的没有带红色,这个问题还没有学到。。

猜你喜欢

转载自blog.csdn.net/weixin_44239550/article/details/128665369