通用组件-eval异常
This commit is contained in:
@@ -41,7 +41,7 @@ export class CommonTableComponent<T> implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
if (!this.request) return
|
if (!this.request || !this.request.path) return
|
||||||
this.getData();
|
this.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,9 +71,14 @@ export class CommonTableComponent<T> implements OnInit, OnChanges {
|
|||||||
let str = `this.dataList.list[${index}].` + fieldValue;
|
let str = `this.dataList.list[${index}].` + fieldValue;
|
||||||
const regexp = /<|>|=|onload|$|{|}|《/
|
const regexp = /<|>|=|onload|$|{|}|《/
|
||||||
str = str.replace(regexp, '');
|
str = str.replace(regexp, '');
|
||||||
|
let value;
|
||||||
|
try {
|
||||||
// tslint:disable-next-line:no-eval
|
// tslint:disable-next-line:no-eval
|
||||||
const value = eval(str);
|
value = eval(str);
|
||||||
return value !== undefined ? value : '暂无数据';
|
} catch (e) {
|
||||||
|
value = null
|
||||||
|
}
|
||||||
|
return (value != null) ? value : '————';
|
||||||
}
|
}
|
||||||
|
|
||||||
getContext = (fieldValue: string, index: number) => {
|
getContext = (fieldValue: string, index: number) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user