0

I am trying to replace loading v-tooltip's VPopper component from standard loading to asynchronous loading.

Standard loading - component loaded and working normally

import { VPopover } from 'v-tooltip'

export default {
  components: {
    VPopover
  }
}

Asynchronous load - component not loaded correctly

export default {
  components: {
    VPopover: () => import('v-tooltip')
  },
}

For some reason above is not working and component is not loaded correctly. Maybe because it’s not a default export but named export in the v-tooltip Vue component?

I am using Webpack in-behind.

If I load my custom component asynchronously then it works as expected. For example this is working for me:

export default {
  components: {
    MyCustomComponent: () => import('@/components/MyCustomComponent.vue')
  }
}
3
  • The lazy module import returns a Promise with the module export, in your case an object containing the named export. Vue don't know what of the named exports should import, so, simply does nothing. Just export the component as default. Commented Jan 14, 2019 at 14:15
  • @gugadev Hmm okay I understand. It's not my component but a v-tooltip package component installed via npm and included into package.json. Anything else I can do or will I have to fork the package and fix this? Commented Jan 14, 2019 at 14:39
  • Just create a wrapper where import the library and export it as default: import { SomeName } from 'v-tooltip'; export default SomeName;. Commented Jan 14, 2019 at 14:56

1 Answer 1

1

Like @gugadev has noted above

The lazy module import returns a Promise with the module export, in your case an object containing the named export. Vue don't know what of the named exports should import, so, simply does nothing.

I found this solution that works

export default {
  components: {
    VPopover: () => import('v-tooltip').then(m => m.VPopover)
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.