search

Home  >  Q&A  >  body text

javascript - vue refresh page

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

仅有的幸福仅有的幸福2756 days ago746

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-19 10:41:55

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

    reply
    0
  • 为情所困

    为情所困2017-05-19 10:41:55

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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-19 10:41:55

    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();    
        },
      }
    })

    reply
    0
  • Cancelreply