1/* 2 * Copyright (c) 2022-2024 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 16/* 17 This test case is used to verify the presence of custom components decorated by @ReusbaleV2 in the template attribute of the Repeat component. 18 */ 19@Entry 20@ComponentV2 21struct validateReusableV2InRepeat { 22 @Local arr:string[] = ['1','2','3']; 23 build() { 24 Column() { 25 List() { 26 Repeat<string>(this.arr) 27 .each((obj: RepeatItem<string>) => {}) 28 .virtualScroll() 29 .template('temp', (obj: RepeatItem<string>) => { ListItem() { 30 Column() { Row() { V2R() } } } }) 31 } 32 Tabs() { 33 Repeat<string>(this.arr) 34 .each((obj: RepeatItem<string>) => {}) 35 .virtualScroll() 36 .template('temp', (obj: RepeatItem<string>) => { 37 Repeat<string>(this.arr) 38 .each((obj: RepeatItem<string>) => {}) 39 .virtualScroll() 40 .template('temp', (obj: RepeatItem<string>) => { TabContent() { 41 Row() { 42 List() { ListItem() { V2R() } } 43 ForEach(this.arr,()=>{ 44 V2R() 45 List() { ListItem() { V2R() } } }) 46 if (this.arr.length === 1) { 47 V2R() 48 } else if (this.arr.length ===2) { 49 V2R() 50 } else { 51 if (this.arr.length) { 52 V2R() 53 } 54 V2R() 55 }}} })})}} 56 } 57} 58 59@ReusableV2 60@ComponentV2 61export struct V2R { 62 build() {} 63}