question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any examples for vue2-sfc-loader?

See original GitHub issue

I can’t seem to figure out how to use the vue2-sfc-loader. If I simply include https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue2-sfc-loader.js, nothing seems to get added to the window object, so code like

const { loadModule } = window['vue3-sfc-loader'];

or

const { loadModule } = window['vue2-sfc-loader'];

just fails. Does the Vue 2 version work different from the Vue 3 version somehow? Unfortunately there are no example for the Vue 2 version, and I really don’t want to dig through the minified source to try and find out how this is supposed to work, so it would be good if you could provide an example of how the Vue 2 version is supposed to be used.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jangxxcommented, Mar 18, 2021

It’s as simple as

const app = Vue.createApp({
    components: {
        'my-component': () => loadModule('./myComponent.vue', options)
    },
    template: '<my-component></my-component>'
});

apparently. Sorry for the issue spam.

1reaction
jangxxcommented, Mar 18, 2021

You don’t have to wait for the module to be ready though. You can simply specify a function as the component which returns a promise resolving to the component later: https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue2-sfc-loader - npm
Single File Component loader for Vue2. Latest version: 0.8.4, last published: a year ago. Start using vue2-sfc-loader in your project by ...
Read more >
Vue Single-File Component (SFC) Spec - Vue Loader
Webpack loader for single-file Vue components.
Read more >
vue2-sfc-loader - npm Package Health Analysis - Snyk
Vue3/Vue2 Single File Component loader. Load .vue files dynamically at runtime from your html/js. No node.js environment, no (webpack) build step needed. Key ......
Read more >
vue2-sfc-loader 0.8.4 on npm - Libraries.io
Vue3 Single File Component loader. Load .vue files dynamically at runtime from your html/js. No node.js environment, no (webpack) build step ...
Read more >
Paul Hammant's Blog: - Buildless SFC VueJS Applications
Vue.JS has a super-cool “Single File Components” (SFC) capability. These are files that contain a component's HTML, JS and CSS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found