Skip to content
Discussion options

You must be logged in to vote

this is because the Comp is not an async component. it would help if you wrapped it like the below:

import { h, ref, unref } from 'vue';
import SlowComponent from './SlowComponent.vue';

function defAsyncComponent(
  comp,
  delay = 0
) {
  return {
    setup(props, { slots }) {
      const p = new Promise(resolve => {
        setTimeout(() => {
          resolve(() => h(comp, props, slots))
        }, delay)
      })
      return p
    }
  }
}
 
export function useRenderSlowComponent() {
  const Comp = defAsyncComponent({
    props:['state'],
    render() {
      return h(
        SlowComponent,
        {
          data: this.state,
        },
        null
      )
    }
  },2000) // this…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
5 replies
@stenet
Comment options

@liulinboyi
Comment options

@stenet
Comment options

@liulinboyi
Comment options

@stenet
Comment options

Comment options

You must be logged in to vote
2 replies
@liulinboyi
Comment options

@stenet
Comment options

Answer selected by edison1105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants