Created
January 29, 2025 15:29
-
-
Save leemartin/416c08928c4d851d67fe46bb0b4c9e30 to your computer and use it in GitHub Desktop.
Load image util for Vue written in Typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (url: string): Promise<HTMLImageElement> => { | |
// Promise | |
return new Promise((resolve, revoke) => { | |
// Image | |
let img = new Image() | |
// On load | |
img.onload = () => { | |
// Resolve | |
resolve(img) | |
} | |
// Source | |
img.src = url | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment