通用组件-eval异常

This commit is contained in:
禾几海
2020-07-01 22:44:42 +08:00
parent 3330d0a090
commit c96b4d90da

View File

@@ -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, '');
// tslint:disable-next-line:no-eval let value;
const value = eval(str); try {
return value !== undefined ? value : '暂无数据'; // tslint:disable-next-line:no-eval
value = eval(str);
} catch (e) {
value = null
}
return (value != null) ? value : '————';
} }
getContext = (fieldValue: string, index: number) => { getContext = (fieldValue: string, index: number) => {