mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: 修复 visibleOn 新公式用法结果为 undefined 时的依然可见的问题 (#5408)
This commit is contained in:
parent
7bd10e3f8b
commit
443ec336ad
@ -68,7 +68,7 @@ export function evalExpression(expression: string, data?: object): boolean {
|
||||
expression[expression.length - 1] === '}'
|
||||
) {
|
||||
// 启用新版本的公式表达式
|
||||
return evalFormula(expression, data);
|
||||
return !!evalFormula(expression, data);
|
||||
}
|
||||
|
||||
// 后续改用 FormulaExec['js']
|
||||
|
@ -62,6 +62,9 @@ test('formula:expression3', () => {
|
||||
// expect(evalFormual('${a} === "b"', {a: 'b'})).toBe(true);
|
||||
expect(evalFormual('b === "b"')).toBe(false);
|
||||
// expect(evalFormual('${a}', {a: 'b'})).toBe('b');
|
||||
|
||||
expect(evalFormual('obj.x.a', {obj: {x: {a: 1}}})).toBe(1);
|
||||
expect(evalFormual('obj.y.a', {obj: {x: {a: 1}}})).toBe(undefined);
|
||||
});
|
||||
|
||||
test('formula:if', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user