| 123456789101112131415161718192021222324252627282930313233 |
- export const loadJs = (url) => {
- return new Promise((resolve, reject) => {
- const script = document.createElement('script')
- script.src = url
- script.type = 'text/javascript'
- document.body.appendChild(script)
- script.onload = () => {
- resolve()
- }
- })
- }
- export const loadCss = (url) => {
- return new Promise((resolve, reject) => {
- const link = document.createElement('link')
- link.rel = 'stylesheet'
- link.href = url
- document.head.appendChild(link)
- link.onload = () => {
- resolve()
- }
- })
- }
- export const generateUUID = () => {
- var d = new Date().getTime();
- var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = (d + Math.random()*16)%16 | 0;
- d = Math.floor(d/16);
- return (c=='x' ? r : (r&0x7|0x8)).toString(16);
- });
- return uuid;
- }
|