注:图片地址(需要在服务器环境下 base64不需要)
引入: cropper.css jquery.js cropper.js
1 2 3 | <link rel="stylesheet" href="css/cropper.css"> <script src="js/cropper.js"></script> |
调用插件:
1 2 3 4 5 6 7 8 9 10 11 12 | Model_Cropper({ imgUrl: img, // 图片地址 / 或者 base64 注:图片地址(需要在服务器环境下 base64不需要) proportion: [100, 100], // 宽/高 裁剪and压缩比例 单位px 图片等比例压缩至 200px/200px confirm: function(result) { // 裁剪成功后 返回的 事件 // 调用 result.close() 关闭弹框 // result.data 为对象 base64 = 处理后base64码 blob = 图片对象 console.log(result) console.log('blob对象=======', result.data.blob) console.log('base64=======', result.data.base64) alert('打开控制台查看 裁剪压缩返回数据') },}) |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com