vue-model icon indicating copy to clipboard operation
vue-model copied to clipboard

SSR support

Open dvasyliev opened this issue 7 years ago • 0 comments

Hi, very nice implementation of models in Vue! Could you provide integration with SSR or help me, how I can do it?

I did my SSR like here and I need to get model variable in asyncData hook like in this example we have store variable (also we have ability to register store module):

export default {
  asyncData ({ store }) {
    store.registerModule('foo', fooStoreModule)
    return store.dispatch('foo/inc')
  },
  ...
}

Source of code

With models it should be like this:

import MyModel from './myModel.js'

export default {
  asyncData ({ model }) {
    const myModel = model('myModel', myModel)
    return myModel.http. fetch()
  },
  ...
}

It will help me load data to my model on the server side and when my page rendered, my model will be filled. Nowadays SSR very popular and a lot of people use it!

If you need some help about SSR explanation you can write me. Thank you!

dvasyliev avatar Jun 24 '18 06:06 dvasyliev