//跳转传参
//跳转item对象
allocationas(item){
this.$router.push({path:'/pindex/regionDate',query:{iten: JSON.stringify(item)}});
},
//获得参数
<template>
<div>{{item}}</div>
</template>
<script>
export default {
data(){
return {
item:[]
}
},
created(){
var item = JSON.parse(this.$route.query.iten);
this.item = item;
console.log(22)
console.log(this.item)
},
mounted(){
},
methods:{
},
watch: {
'$route' (to, from) { //监听路由是否变化
if(to.path == "/pindex/regionDate"){
var item = JSON.parse(this.$route.query.iten);
this.item = item;
console.log(11)
console.log(this.item)
}
}
},
}
</script>
vue传参对象和监听
于 2021-08-20 10:30:43 首次发布