You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
890 B

  1. import { Message } from 'element-ui'
  2. export default function (file, width, height) {
  3. return new Promise(resolve => {
  4. let reader = new FileReader();
  5. reader.readAsDataURL(file);
  6. reader.onload = function (e) {
  7. let txt = e.target.result;
  8. let img = document.createElement("img");
  9. img.src = txt;
  10. img.onload = function () {
  11. if (img.width === width && img.height === height) {
  12. resolve(true)
  13. } else {
  14. Message({
  15. message: `图片上传失败,宽高错误`,
  16. type: "warning",
  17. duration: 5000
  18. });
  19. resolve(false);
  20. }
  21. };
  22. };
  23. })
  24. }
  25. // 1. 650 350
  26. // 1. 650 350
  27. // 1. 650 350
  28. // 1. 650 350
  29. // 1. 650 350