Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created January 29, 2025 15:29
Show Gist options
  • Save leemartin/416c08928c4d851d67fe46bb0b4c9e30 to your computer and use it in GitHub Desktop.
Save leemartin/416c08928c4d851d67fe46bb0b4c9e30 to your computer and use it in GitHub Desktop.
Load image util for Vue written in Typescript
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