diff --git a/packages/amis-core/src/utils/isPureVariable.ts b/packages/amis-core/src/utils/isPureVariable.ts index e06d2fd45..d5332b46f 100644 --- a/packages/amis-core/src/utils/isPureVariable.ts +++ b/packages/amis-core/src/utils/isPureVariable.ts @@ -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; }