FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.15k stars 121 forks source link

Export a function to load a module from a string #3

Closed maximdeclercq closed 3 years ago

maximdeclercq commented 3 years ago

Fixes #2

FranckFreiburger commented 3 years ago

for the record

Look at https://github.com/FranckFreiburger/vue3-sfc-loader/blob/main/docs/interfaces/options.md#getfile You can define options.getFile() like this:

      getFile(url) {

        if ( url === 'MY_ID' )
          return Promise.resolve(theComponentString);

        return fetch(url).then(response => response.ok ? response.text() : Promise.reject(response));
      },