|
@@ -106,30 +106,62 @@ export class SImageItem extends SObjectItem {
|
|
|
set url(v: string) {
|
|
|
this._url = v;
|
|
|
this.img = new Image();
|
|
|
+ // Edge 获取不到e.path
|
|
|
this.img.onload = (e): void => {
|
|
|
- // @ts-ignore
|
|
|
- const imgSrc = e.path[0].src;
|
|
|
- /**
|
|
|
- * 需要解决两个问题,此方法仅用
|
|
|
- * 1 需要把 imgSrc 做转意;
|
|
|
- * 2 添加兼容 Ios 方法(e.path[0].src在 ios无此属性)
|
|
|
- */
|
|
|
- // if (this.isUrlIdentical(imgSrc)) {
|
|
|
+ const isiOS = !!navigator.userAgent.match(
|
|
|
+ /\(i[^;]+;( U;)? CPU.+Mac OS X/
|
|
|
+ ); //ios终端
|
|
|
+ try {
|
|
|
+ if (isiOS) {
|
|
|
+ this.isLoadOver = true;
|
|
|
+ this.computeImgSize();
|
|
|
+ this.$emit("imgLoadOver");
|
|
|
+ this.update();
|
|
|
+ } else {
|
|
|
+ // @ts-ignore
|
|
|
+ const imgSrc = e.path[0].src;
|
|
|
+ if (this.isUrlIdentical(imgSrc)) {
|
|
|
+ this.isLoadOver = true;
|
|
|
+ this.computeImgSize();
|
|
|
+ this.$emit("imgLoadOver");
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ } finally {
|
|
|
this.isLoadOver = true;
|
|
|
this.computeImgSize();
|
|
|
this.$emit("imgLoadOver");
|
|
|
this.update();
|
|
|
- // }
|
|
|
+ }
|
|
|
};
|
|
|
this.img.onerror = (e): void => {
|
|
|
- // @ts-ignore
|
|
|
- const imgSrc = e.path[0].src;
|
|
|
- if (this.isUrlIdentical(imgSrc)) {
|
|
|
+ try {
|
|
|
+ const isiOS = !!navigator.userAgent.match(
|
|
|
+ /\(i[^;]+;( U;)? CPU.+Mac OS X/
|
|
|
+ ); //ios终端
|
|
|
+ if (isiOS) {
|
|
|
+ this.isLoadOver = false;
|
|
|
+ this.$emit("imgLoadOver");
|
|
|
+ this.update();
|
|
|
+ } else {
|
|
|
+ // @ts-ignore
|
|
|
+ const imgSrc = e.path[0].src;
|
|
|
+ if (this.isUrlIdentical(imgSrc)) {
|
|
|
+ this.isLoadOver = false;
|
|
|
+ this.$emit("imgLoadOver");
|
|
|
+ this.update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ } finally {
|
|
|
this.isLoadOver = false;
|
|
|
this.$emit("imgLoadOver");
|
|
|
this.update();
|
|
|
- console.log("加载图片错误!", e);
|
|
|
}
|
|
|
+ console.log("加载图片错误!", e);
|
|
|
};
|
|
|
this.img.src = v;
|
|
|
}
|