UNPKG

image-handler

Version:
24 lines 716 B
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <input id="input" type="file" accept="image/*" /> <script src="dist/bundle.js"></script> <script> const input = document.getElementById('input') input.onchange = function(e) { const file = e.target.files[0] console.log(file, '压缩前') imgHandler.compressImage(file).then(res => { console.log(res, '压缩后') console.log(imgHandler.fileToUrl(res), '压缩后url') }) } </script> </body> </html>