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 */ 15import { AppLog } from '../utils/Logger' 16 17const TAG: string = "DEBUG TEST"; 18 19@Component 20export struct myButton { 21 //自定义button 回调函数目前只支持void和无参 22 public logger = new AppLog(TAG); 23 public fun: () => void = () => { 24 }; 25 public text = "This is a button"; 26 @State returnMessage: string = "No"; 27 28 build() { 29 Row() { 30 Column() { 31 Blank().height(40); 32 Button(`${this.text}`) 33 .labelStyle({ 34 overflow: TextOverflow.Clip, 35 maxLines: 2, 36 minFontSize: 20, 37 maxFontSize: 20, 38 font: { 39 size: 20, 40 weight: FontWeight.Bolder, 41 family: 'cursive', 42 style: FontStyle.Italic 43 } 44 }) 45 .onClick(() => { 46 this.logger.log("\n start->>>>>>>>>>>>>>>>>>>>>>"); 47 this.fun(); 48 this.logger.log((this.fun.toString()) + "\n end:->>>>>>>>>>>>>>>>>>>>>>"); 49 this.returnMessage = "Yes"; 50 }) 51 Blank().height(40); 52 Divider(); 53 } 54 } 55 } 56}