2022-02-16 11:20:17 +08:00

20 lines
531 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { isJSExpression, JSExpression } from '@alilc/lowcode-types';
// 1.渲染模式下loop 是数组,则按照数组长度渲染组件
// 2.设计模式下loop 需要长度大于 0按照循环模式渲染防止无法设计的情况
export default function isUseLoop(loop: null | any[] | JSExpression, isDesignMode: boolean): boolean {
if (isJSExpression(loop)) {
return true;
}
if (!Array.isArray(loop)) {
return false;
}
if (!isDesignMode) {
return true;
}
return loop.length > 0;
}