javascript - vue refresh page
仅有的幸福
仅有的幸福 2017-05-19 10:39:55
0
3
743

The project uses the vue1.0 version. Keep-alived is set in the routing jump and an initialization method is defined in ready. Now I have encountered a problem, that is, the page can only be opened for the first time before the data request is made. The request will not be made this time. Looking for a solution

仅有的幸福
仅有的幸福

reply all(3)
迷茫

You can watch routing changes to call the method of requesting data and then render the page

为情所困

keep-alived
You put the request in actived.
Look at the vue life cycle

仅有的幸福

Use hook function to initialize when routing is switched
https://github.com/vuejs/vue-...

Vue.component('hook-example', {
  // ... other options
  route: {
    data: function () {
      this.fetchData();    
    },
  }
})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template