SoFunction
Updated on 2025-04-05

Vue + Vue-router method to switch data without updating with routes with the same name

By default, switching between routes with the same name will not be performed because the component can be taken and placed in ready to obtain data. There are two ways to solve it

Note: This problem exists only in vue1

Method 1: Put the data acquisition below~

route: {
  data({to: {params: { page }}}) {
    return ([
      ()
    ]).then(() => {

    })
  }
}

Method 2: Set = false, force the component to not be reused~

route: {
  canReuse() {
    return false
  }
},
ready() {
  var request = $.ajax({
    type: "POST",
    dataType: 'json',
    url: ""
  });
  ((json) => {
    // balabala
  });
}

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.