Label writing
Use <router-link> to jump. <router-link> will be rendered into a `<a>` tag by default.
- <router-link to="/btn"> Specify link via to </router-link>
- <router-link :to="{ path:'/btn'} "> Jump according to path </router-link>
- <router-link :to="{ name:'user'} "> Jump based on name </router-link>
Programmatic writing
router.go() is similar to js's history.go(), refreshed with 0, forward with positive numbers, and backward with negative numbers.
router.push() adds a route to the history stack,
- router.push('/')
- router.push({path:'/'})
- router.push({name:'home'})
Jump page
import { useRouter} from "vue-router";
const a = useRouter();//返回上一页
const b = () =>{
a.push({
path:'/页面',
})
Passing on parameters
const dianji = () =>{
router.push({
path:'/页面',
query:{
id:参数
}
})
}