You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yes, the solution you are talking about is quite old { content: content, type: ".mjs" } is not valid any more.
In order to handle binary files (ex. png) I managed to change 'content' property into getContentData: (asBinary: Boolean) => Promise<ContentData>
Now, your option.getFile function should look like this:
asyncgetFile(url){constres=awaitfetch(url);if(!res.ok)throwObject.assign(newError(res.statusText+' '+url),{ res });// make test.js be treated as an mjs fileif(url.endsWith("/test.js")){return{getContentData: async(asBinary)=>{// asBinary is unused here, we know it is a text filereturnawaitres.text();},type: ".mjs",}}return{getContentData: asBinary=>asBinary ? res.arrayBuffer() : res.text(),}},
I was getting the following error when trying to use vue.js composables and import a script js file.
'import' and 'export' may appear only with 'sourceType: "module"' (1:0)
I have tried to replicate the solutions here:
#44 and here
#14 (comment)
Specifically this solution:
async getFile(url) {
const res = await fetch(url);
if (!res.ok) throw Object.assign(new Error(url + " " + res.statusText), { res });
let content = await res.text();
content = url.endsWith("/test.js") ? { content: content, type: ".mjs" } : content;
return content;
},
Where the test.js file is :
export const user = {
userName: "root",
password: "zfs1111"
}
is giving me the error: TypeError: t is not a function in the console. I get the same error trying to import a non-test js file.
Is this an old solution that is no longer viable? What is the new solution if yes?
using Vue3.js
Versions
Additional context
The text was updated successfully, but these errors were encountered: