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