VUE2:
跳转页面 并传值
methods:{
goodList(item){
this.$router.push({path:'/跳转的页面路径',query:{自定义名称:要传递的数据}})
}
}
目标页面 接收内容
<script>
export default {
data(){
return{
自定义名称:this.$route.query.obj(传递的数据)
}
}
}
};
VUE3
跳转路由 并传参
setup() {
function gotodetail() {
router.push({path: "/regiter", query: {item: item}});
}
return {gotodetail};
},
行内式写法
@click="$router.push({path: '/regiter', query: {name: item.good_name}})"
接收 <p>{{$route.query.name}}</p>
路由接收跳转 引入路由方法
import {useRoute} from 'vue-router'
const route = useRoute()
<div>{{route.query.name}}</div>
VUE2和VUE3的路由跳转方法以及区别
于 2021-12-25 12:06:28 首次发布