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 */ 15const gloabel_value: string = "Foo" 16const obj: paramA = { 17 gloabel_value: "Foo" 18} 19class paramA { 20 gloabel_value: string = "Foo" 21} 22@Entry 23@ComponentV2 24struct validateParamTwoWayBind { 25 @Local local_value: string = "Foo" 26 obj: paramA = { 27 gloabel_value: "Foo" 28 } 29 aa() { 30 return { 31 gloabel_value: "Foo" 32 } as paramA 33 } 34 bb() { 35 return "Foo"; 36 } 37 build() { 38 Column() { 39 testParamChild1({value: this.local_value!!}) 40 testParamChild2({paramValue: this.obj?.gloabel_value!!}) 41 testParamChild2({paramValue: this.aa()?.gloabel_value!!}) 42 testParamChild2({paramValue: this.bb()!!}) 43 testParamChild2({paramValue: "hello"!!}) 44 testParamChild2({paramValue: "hello"!!!}) 45 testParamChild2({paramValue: this.local_value!!!}) 46 } 47 } 48} 49 50@ComponentV2 51struct testParamChild1 { 52 @Param value: string = "hello" 53 build() {} 54} 55 56@ComponentV2 57struct testParamChild2 { 58 @Param paramValue: string = "hello" 59 @Event $paramValue: (value: string) => void = (value: string) => {} 60 build() {} 61}