search

Home  >  Q&A  >  body text

javascript - In vue server-side rendering, after looking at several examples, why do they all use vuex to obtain and store data? Why not get it directly from the request in the component? what is the benefit?

Official example

function fetchItem (store) {
  return store.dispatch('FETCH_ITEMS', {
    ids: [store.state.route.params.id]
  })
}

Why not just use:

function fetchItem (store) {
  //发起http请求
    axios({url:**})....
}
巴扎黑巴扎黑2837 days ago450

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:48:25

    https://github.com/vuejs/vue-...

    This is the author’s answer

    reply
    0
  • Cancelreply