the problem is that the first click of the previous route will go through the method in mounted, and the second click will not go again because the component will not be remounted, but I need to re-query the data according to the passed parameters when I click navigation again, and the data bound by the current component will also be re-mounted
.
now is the effect of the first time I clicked on the men"s wear, but the page will not change when I click on the women"s wear, because there is no re-entry to the mounted, below this is the code, and the data here is the data I did the test simulation.
mounted () {
this.type=this.$route.query.type;
if(this.type=="2"){
this.data="";
this.data=[
{
img:"m1.jpg",
name:"",
id:"M1",
price:"100",
},
{
img:"m2.jpg",
name:"",
id:"M2",
price:"199",
},
{
img:"m3.jpg",
name:"",
id:"M3",
price:"135",
},
{
img:"m4.jpg",
name:"",
id:"M4",
price:"288",
},
{
img:"m5.jpg",
name:"",
id:"M5",
price:"155",
},
{
img:"m6.jpg",
name:"",
id:"M6",
price:"300",
}
];
alert(this.data);
}else if(this.type=="3"){
alert(this.type);
this.data="";
this.data=[
{
img:"clothes1.jpg",
name:"",
id:"W1",
price:"100",
},
{
img:"clothes2.jpg",
name:"",
id:"W2",
price:"199",
},
{
img:"clothes3.jpg",
name:"",
id:"W3",
price:"135",
},
{
img:"clothes4.jpg",
name:"",
id:"W4",
price:"288",
},
{
img:"clothes5.jpg",
name:"",
id:"W5",
price:"155",
},
{
img:"clothes6.jpg",
name:"",
id:"W6",
price:"300",
}
];
}
mounted