Browse Source

feat: 无jira任务 当图片不存在时,显示默认图片

qufenxi
alan 5 years ago
parent
commit
036bc69364
  1. 17
      src/modules/pages/database/database_type/database_type.ts

17
src/modules/pages/database/database_type/database_type.ts

@ -20,6 +20,8 @@ export class DatebaseType extends BI.BasicButton {
baseCls: 'dec-dcm-datebase-type', baseCls: 'dec-dcm-datebase-type',
} }
img: any;
store: DatebaseTypeModel['store']; store: DatebaseTypeModel['store'];
render() { render() {
@ -37,6 +39,9 @@ export class DatebaseType extends BI.BasicButton {
el: { el: {
type: Img, type: Img,
src: iconUrl ? iconUrl : `${ImgPrefix}${databaseType}.jpg`, src: iconUrl ? iconUrl : `${ImgPrefix}${databaseType}.jpg`,
ref: (_ref: any) => {
this.img = _ref;
},
}, },
height: 90, height: 90,
}, },
@ -62,4 +67,16 @@ export class DatebaseType extends BI.BasicButton {
const { value } = this.options; const { value } = this.options;
this.store.setDatebaseTypeSelected(value); this.store.setDatebaseTypeSelected(value);
} }
mounted() {
this.setDefaultImg();
}
private setDefaultImg() {
const ImgObj = new Image();
ImgObj.src = this.img.getSrc();
ImgObj.onerror = () => {
this.img.setSrc(`${ImgPrefix}other.jpg`);
};
}
} }

Loading…
Cancel
Save