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 { 17 Component, 18 State, 19 Row, 20 Slider, 21 $$, 22 Checkbox, 23 Blank, 24 Text, 25 Entry, 26 ComponentV2, 27 Local, 28 Column, 29 Button, 30 Param, 31 Event, 32} from '@kit.ArkUI'; 33 34import { MyCard } from './' 35 36@Component 37struct MyComponent1 { 38 @State value: number = 0.0 39 40 build() { 41 Row() { 42 Slider({ 43 value: $$(this.value) 44 }) 45 } 46 } 47} 48 49@Component 50struct Test { 51 @State checked: boolean = false 52 53 build() { 54 Row() { 55 Checkbox().select($$(this.checked)) 56 Blank() 57 Text(this.checked ? '开启': '关闭') 58 } 59 } 60} 61 62@Component 63struct MyComponent2 { 64 @State value: number = 0.0; 65 build() { 66 Row() { 67 Slider({ 68 value: this.value!!! 69 }) 70 } 71 } 72} 73 74@Component 75struct MyComponent3 { 76 @State value: number = 0.0; 77 build() { 78 Row() { 79 Slider({ 80 value: this.value!!!! 81 }) 82 } 83 } 84} 85 86@Component 87struct MyComponent4 { 88 @State value: number = 0.0; 89 build() { 90 Row() { 91 Slider({ 92 value: this.value!!!!! 93 }) 94 } 95 } 96} 97 98@Entry 99@ComponentV2 100struct Index { 101 @Local value: number = 0.0; 102 @Local str: string = ''; 103 104 build() { 105 Column() { 106 Text(`${this.value}`) 107 Button(`change value`).onClick(() => { 108 this.value++; 109 }) 110 Star({ 111 value: this.value, 112 $value: value => { 113 this.value = value; 114 } 115 }) 116 MyCard({ 117 str: this.str, 118 $str: value => { 119 this.str = value; 120 } 121 }) 122 } 123 } 124} 125 126 127@ComponentV2 128struct Star { 129 @Param value: number = 0.0; 130 @Event $value: (val: number) => void = (val: number) => {}; 131 132 build() { 133 Column() { 134 Text(`${this.value}`) 135 Button(`change value `).onClick(() => { 136 this.$value(10.0); 137 }) 138 } 139 } 140}