filter 改放第二个参数

This commit is contained in:
2betop 2020-01-08 09:24:28 +08:00
parent 116154d1b0
commit 6bfa6bc502

View File

@ -53,10 +53,11 @@ export function evalExpression(expression: string, data?: object): boolean {
const fn = new Function(
'data',
'utils',
`with(data) {${debug ? 'debugger;' : ''}return !!(${expression});}`
);
data = data || {};
return fn.call(createObject(getFilters(), data), data);
return fn.call(data, data, getFilters());
} catch (e) {
console.warn(e);
return false;
@ -68,10 +69,11 @@ export function evalJS(js: string, data: object): any {
try {
const fn = new Function(
'data',
'utils',
`with(data) {${~js.indexOf('return') ? '' : 'return '}${js};}`
);
data = data || {};
return fn.call(createObject(getFilters(), data), data);
return fn.call(data, data, getFilters());
} catch (e) {
console.warn(e);
return null;