1/* 2 * Copyright (c) 2025 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 16import { MyCard } from './' 17 18@Component 19struct MyComponent1 { 20 @State value: number = 0 21 22 build() { 23 Row() { 24 Slider({ 25 value: this.value!! 26 }) 27 } 28 } 29} 30 31@Component 32struct Test { 33 @State checked: boolean = false 34 35 build() { 36 Row() { 37 Checkbox().select(this.checked!!) 38 Blank() 39 Text(this.checked ? '开启': '关闭') 40 } 41 } 42} 43 44@Component 45struct MyComponent2 { 46 @State value: number = 0; 47 build() { 48 Row() { 49 Slider({ 50 value: this.value!!! 51 }) 52 } 53 } 54} 55 56@Component 57struct MyComponent3 { 58 @State value: number = 0; 59 build() { 60 Row() { 61 Slider({ 62 value: this.value!!!! 63 }) 64 } 65 } 66} 67 68@Component 69struct MyComponent4 { 70 @State value: number = 0; 71 build() { 72 Row() { 73 Slider({ 74 value: this.value!!!!! 75 }) 76 } 77 } 78} 79 80@Entry 81@ComponentV2 82struct Index { 83 @Local value: number = 0; 84 @Local str: string = ''; 85 86 build() { 87 Column() { 88 Text(`${this.value}`) 89 Button(`change value`).onClick(() => { 90 this.value++; 91 }) 92 Star({ value: this.value!! }) 93 MyCard({ str: this.str!! }) 94 } 95 } 96} 97 98 99@ComponentV2 100struct Star { 101 @Param value: number = 0; 102 @Event $value: (val: number) => void = (val: number) => {}; 103 104 build() { 105 Column() { 106 Text(`${this.value}`) 107 Button(`change value `).onClick(() => { 108 this.$value(10); 109 }) 110 } 111 } 112}