forked from p96170835/amis
evalJs 优化是否补 return 的判断
This commit is contained in:
parent
dc24cd30e2
commit
4977813a06
|
@ -70,7 +70,7 @@ export function evalJS(js: string, data: object): any {
|
||||||
const fn = new Function(
|
const fn = new Function(
|
||||||
'data',
|
'data',
|
||||||
'utils',
|
'utils',
|
||||||
`with(data) {${~js.indexOf('return') ? '' : 'return '}${js};}`
|
`with(data) {${/^\s*return\b/.test(js) ? '' : 'return '}${js};}`
|
||||||
);
|
);
|
||||||
data = data || {};
|
data = data || {};
|
||||||
return fn.call(data, data, getFilters());
|
return fn.call(data, data, getFilters());
|
||||||
|
|
Loading…
Reference in New Issue