1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15@Component 16export struct FrameTimelineBeforeOptimization { 17 // 创建长度500的空数组,使用每个元素的索引作为元素的值,生成包含数字0-499的数组 18 @State children: number[] = Array.from<undefined, number>(Array(500).fill(undefined), (item: undefined, index) => index); 19 build() { 20 Scroll() { 21 Grid() { 22 ForEach(this.children, (item: number) => { 23 GridItem() { 24 Stack() { 25 Stack() { 26 Stack() { 27 Text(item.toString()) 28 .fontSize(32) 29 } 30 } 31 } 32 } 33 }, (item: number) => item.toString()) 34 } 35 .columnsTemplate('1fr 1fr 1fr 1fr') 36 .columnsGap(0) 37 .rowsGap(0) 38 .size({ width: "100%", height: "100%" }) 39 } 40 } 41}