In fact, click on an element to trigger the event and use the method to jump. One of the most commonly used methods is recorded here.
It should be noted that: this.$router.push
in, it is router, not routes. Sometimes vscode prompts an error and it will be wrong.
<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>
You can also find that the jump is not red, and this problem has not been learned yet. .