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.19k stars 127 forks source link

Disabled vue3-sfc-loader cache #122

Closed flagellarmirror closed 2 years ago

flagellarmirror commented 2 years ago

Hi, is it possible to disable the cache of vue3-sfc-loader? I need it because every time I change vue components the only way I have to see the changes is to clear the cache. When I was using httpvueloader I had solved it by adding a timestamp as a query string when importing a component, is it possible to do that again?

GodsVictory commented 2 years ago

how did you get this working? I'm facing the same issue

dizheyoulan commented 2 years ago

how did you get this working? I'm facing the same issue

edit options.getFile

const options = { moduleCache: { vue: Vue }, async getFile(url) { const res = await fetch(url+'?'+Date.parse( new Date() ).toString()); if (!res.ok)throw Object.assign(new Error(res.statusText + ' ' + url), { res }); return { getContentData: asBinary => asBinary ? res.arrayBuffer() : res.text(), } }, addStyle(textContent) { const style = Object.assign(document.createElement('style'), { textContent }); const ref = document.head.getElementsByTagName('style')[0] || null; document.head.insertBefore(style, ref); }, }

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