Loading Images in Components #60
-
i am getting an error from createVue3SFCModule.ts:305. Is there a workaround to bringing images in? in the component: the following is the config: const options = {
moduleCache: {
vue: Vue,
},
async getFile(url) {
const res = await fetch(url);
if (!res.ok)
throw Object.assign(new Error(url + " " + res.statusText), { res });
return await 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"];
const app = Vue.createApp({
components: {
vLayout: Vue.defineAsyncComponent(() =>
loadModule("components/vLayout.vue", options)
),
},
template: "<vLayout></vLayout>",
});
app.mount("#app"); edit: using vs-code and live-server. i saw one github issue with live-serve sending incorrect mime types, so can't be certain it is sfc-loader. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I need to add binary data support. Work in progress ... |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, here's my code extract of index.html
Club.vue
|
Beta Was this translation helpful? Give feedback.
-
I don't know if any of this is still maintained, but as of Jan 5th 2024, that bug is still present, or the solution is still NOT clear from the circling "See #69"=>"See #60". So i'll write my easy work around the problem : I have a logo component : Logo.vue
Basically changes the img src once the tag has been created in the dom, so vue-sfc-loader doesn't think it's loading a file (I think, idc, it works without error messages now) edit: formatting |
Beta Was this translation helpful? Give feedback.
-
I've just added an example of image loading: |
Beta Was this translation helpful? Give feedback.
I need to add binary data support. Work in progress ...