The parameters passed by the previous route click navigation are used in the current route. The data is rendered only on the first click, but not re-rendered on the second click.

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

.

clipboard.png
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
Mar.11,2021

first figure out how your tabs are made. Whether it is a routing handover or an id handover. If it is a routing switch, the click will certainly be executed to mounted;. If the id switch shows different content, then go to watch to listen for the flag change during the handover. Listen for a change and re-perform a data refresh.

the method of data refresh is unloaded within the method. To call in mounted and watch.


there is another problem. I encountered the same thing as you before. The page will not be refreshed again, and the final solution is that after all the errors are solved, it will be normal

.
Menu