-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobals.js
35 lines (33 loc) · 1.2 KB
/
globals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Use this file to register any variables or functions that should be available
* ideally you should make it available via the window object
* as well as the Vue prototype for access throughout the app
* (register globals with care, only when it makes since to be accessible app
*/
// Define as opções para o vue2-sfc-loader
function load(path) {
const options = {
moduleCache: {
vue: Vue
},
async getFile(url) {
const res = await fetch(url);
if (!res.ok) {
throw Object.assign(new Error(res.statusText + ' ' + url), { res });
}
return {
getContentData: (asBinary) => asBinary ? res.arrayBuffer() : res.text(),
}
},
addStyle(styleStr) {
const style = document.createElement('style');
style.textContent = styleStr;
const ref = document.head.getElementsByTagName('style')[0] || null;
document.head.insertBefore(style, ref);
},
log(type, ...args) {
console.log(type, ...args);
}
};
return window["vue2-sfc-loader"].loadModule(path, options);
}