mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-16 23:02:50 +00:00
20 lines
531 B
TypeScript
20 lines
531 B
TypeScript
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;
|
||
}
|