split.js 507 B

12345678910111213141516171819202122232425
  1. import Vue from '../../../dist/vue.runtime.common.js'
  2. // async component!
  3. const Foo = () => import('./comp')
  4. export default context => {
  5. return new Promise(resolve => {
  6. context.msg = 'hello'
  7. const vm = new Vue({
  8. render (h) {
  9. return h('div', [
  10. context.url,
  11. h(Foo)
  12. ])
  13. }
  14. })
  15. // simulate router.onReady
  16. Foo().then(comp => {
  17. // resolve now to make the render sync
  18. Foo.resolved = Vue.extend(comp)
  19. resolve(vm)
  20. })
  21. })
  22. }