fix: 修复数据映射复杂写法没有正确返回原始数据的问题

This commit is contained in:
2betop 2022-06-16 11:53:25 +08:00
parent c0e4b82ff9
commit f933762415

View File

@ -1,5 +1,15 @@
import {parse} from 'amis-formula';
export function isPureVariable(path?: any): path is string {
return typeof path === 'string'
? /^\$(?:((?:\w+\:)?[a-z0-9_.][a-z0-9_.\[\]]*)|{[^}{]+})$/i.test(path)
: false;
if (typeof path === 'string') {
try {
const ast = parse(path);
// 只有一个成员说明是纯表达式模式
return ast.body.length === 1;
} catch (err) {
return false;
}
}
return false;
}