鸿蒙前端使用按钮组件的处理流程

前端使用按钮组件的正确方式

前端代码中,通过 ArkUI 提供的 <Button> 组件即可,框架会自动完成与底层 DOMButton 的关联。以下是具体使用示例:

1. 基础用法(ArkTS 声明式)

typescript

@Entry
@Component
struct ButtonDemo {
  build() {
    Column() {
      // 基础按钮
      Button('点击我')
        .onClick(() => {
          console.log('按钮被点击');
        })

      // 带样式的按钮
      Button('提交')
        .width(120)
        .height(40)
        .fontSize(16)
        .backgroundColor('#007DFF')
        .onClick(() => {
          // 处理提交逻辑
        })

      // 禁用状态按钮
      Button('不可点击')
        .disabled(true) // 禁用按钮
        .backgroundColor('#CCCCCC')
    }
    .padding(20)
  }
}
2. JS 扩展用法(类 HTML 风格)

如果使用 JS 开发,可通过 HML 标签定义按钮:

html<

华为鸿蒙开发:自定义组件的创建与使用 在华为鸿蒙应用的开发中,自定义组件是构建复杂界面和重用代码的重要手段。通过自定义组件,开发者可以将复杂的UI逻辑封装起来,提高代码的可维护性和可读性。本文将通过 DevEco Studio 详细介绍如何在鸿蒙应用中创建和使用自定义组件,包括组件的参数传递、状态管理、事件处理以及如何通过@Builder和装饰器自定义组件内容。自定义组件允许我们将UI逻辑封装在一个可重用的单元中。 阅读详情

相关推荐

【鸿蒙开发】—— 添加组件(按钮 (Button)

Button是按钮组件,通常用于响应用户的点击操作,其类型包括胶囊按钮、圆形按钮、普通按钮。Button做为容器使用时可以通过添加子组件实现包含文字、图片等元素的按钮。具体用法请参考 Button 。

2401_88547687的博客 2362

HarmonyOS2.0 华为鸿蒙开发学习实战教程

据统计,鸿蒙系统升级用户2周破1800万,1个月突破3000万。升级速度完全超出市场预期,很显然,华为严重低估了消费者的支持热情。随即,华为鸿蒙目标多次升级,从2亿到4亿,后年目标12.3亿。 而且,目前国内有很多家软硬件厂商已经加入了鸿蒙。格力董事长董明珠在近日接受外媒采访时表示:格力将引入鸿蒙操作系统。 对应用开发者而言,HarmonyOS采用了多种分布式技术,使得应用程序的开发实现与不同终端设备的形态差异无关,降低了开发难度和成本。这能够让开发者聚焦上层业务逻辑,更加便捷、高效地开发应用。 作为万物互

Aa112233aA1的博客 2041

鸿蒙HarmonyOS APP开发入门3——组件(九 按钮组件 )—

(img-pbD28Map-1713213081878)]利用圆形按钮,胶囊按钮,文本组件可以绘制出如下拨号盘的UI界面。

2401_84181340的博客 841

鸿蒙HarmonyOS 【ArkTS组件】 焦点事件

焦点事件指页面焦点在可获焦组件间移动时触发的事件,组件可使用焦点事件来处理相关逻辑。说明从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。目前仅支持通过外接键盘的tab键、方向键触发。不支持嵌套滚动组件场景按键走焦。存在默认交互逻辑的组件例如Button、TextInput等,默认即为可获焦,Text、Image等组件默认状态为不可获焦,不可获焦状态下,无法触发焦点事件,需要设置focusable属性为true才可触发。焦点开发参考焦点开发指南。

zhangQ2013的博客 1019

鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Button按钮组件

给组件添加点击事件的回调,设置该回调后,当点击组件时会触发该回调。鸿蒙(HarmonyOS)项目方舟框架(ArkUI)之Button按钮组件。从API version 9开始,该接口支持在ArkTS卡片中使用。组件也是基础组件之一,和其它基础组件不同的是。组件允许添加一个子组件来实现不同的展示样式。操作系统: Windows 10 专业版。按钮最主要的就是点击事件了。二、Button按钮组件。

weixin_47730343的博客 1781

HarmonyOS核心知识点:按钮 (Button)组件

设置边框弧度。使用通用属性来自定义按钮样式。例如通过borderRadius属性设置按钮的边框弧度。设置文本样式。通过添加文本样式设置按钮文本的展示样式。设置背景颜色。添加backgroundColor属性设置按钮的背景颜色。创建功能型按钮。为删除操作创建一个按钮。

wuliusan5的博客 2183

七、华为鸿蒙HarmonyOS应用开发之Java UI框架、常用Text组件和Button组件使用

一、Java UI框架概述 应用的Ability在屏幕上将显示一个用户界面,该界面用来显示所有可被用户查看和交互的内容。 应用中所有的用户界面元素都是由Component和ComponentContainer对象构成。Component是绘制在屏幕上的一个对象,用户能与之交互。ComponentContainer是一个用于容纳其他Component和ComponentContainer对象的容器。 Java UI框架提供了一部分Component和ComponentContainer的具体子类,即创建用户界

星如雨落 1830

华为鸿蒙HarmonyOS Java 布局开发

在HarmonyOS应用中,所有的用户界面元素都是由 Component和ComponentContainer对象构成。 Component 是绘制在屏幕上的一个对象(可类比成Android的View),用户能与之交互。component 提供了内容显示,是界面中所有组件的基类,开发者可以给Component 设置事件处理回调来创建一个可交互的组件。Java UI 框架提供了一些常用的界面元素,也可以称为组件,组件一般直接继承Component 或它的子类,如 Text、Image等 C..

郭宝的博客 3231

yanshee 机器人全流程指南

2.点击yanshee app右上角根据提示操作 3.当手机显示成功连接 ,按下机器人胸前按钮说出“ip地址”4.根据机器人播报的ip地址加上:8888使用浏览器访问,你就会看到 jupyterd的界面,里面可以新建文件也可以改他存在的文件。我们使了yanshee机器人,这个是面向K12、中高职、高校学生推出的开源人形机器人教育平台,应用于课程教学、竞赛、科研活动等场景。我们接下来可以根据这些apl做许多好玩的,比如控制他运动,跳舞唱歌,it`s easy。注意电脑,手机,机器人必须连同一个网。

qq_44827929的博客 7619

如何使用Calibre PERC抽出 点到点/p2p 电阻

@[TOC](如何使用Calibre PERC抽点到点(p2p)电阻) 一、前言 需要实现的功能是从gds中抽出net的点到点的电阻。如下图这样。 二、准备工作 lvs rule pex rule(必要时可以自己定义RC rule) gds p2p点的坐标 定义prode.defs 因为p2p的点是变化的,所以每次prode定义都要重新出,对应的perc rule也是根据每个p2p点的定义来的,perc rule也是每次都要重新出。如果需要可以写一个脚本自动出这些定义文件。 PROBE_POINTS

kobayashiyou的博客 1万+

单细胞分析实录(12): 如何推断肿瘤细胞

公众号后台回复20210418,获取本文的测试数据 1. 回顾 前面我已经讲解了inferCNV的基本用法,这一节继续学习:如何推断肿瘤细胞。本文应该是到目前为止,全网最详细的帖子(之一)。 关于肿瘤细胞的推断,比如研究上皮细胞起源的肿瘤,我见过的一些做法如下 简单粗暴型:将来源肿瘤病灶的所有上皮细胞都看成是肿瘤细胞 看CNV:将来源于肿瘤病灶的上皮细胞和参考细胞比较,将那些有明显CNV的细胞看作肿瘤细胞 看表达特征:考虑到有的肿瘤细胞可能没有CNV层面的变化,有的文章会根据肿瘤与正常的表达谱来区分是.

TOP生物信息 1万+

软件工程实验报告--用Visio绘制数据流图、ER图、状态图、软件结构图、程序流程图、系统流程图

用Visio绘制数据流图、ER图、状态图、软件结构图、程序流程图、系统流程图

m0_73814332的博客 4172

可信数据空间:可信空间、区域功能节点、业务功能节点、连接器的关联关系

可信数据空间通过分层架构实现安全数据共享:可信空间作为顶层制定全局规则;区域功能节点协调辖区内功能节点协作;功能节点提供具体数据服务;连接器作为唯一通信通道确保安全交互。系统采用"规则自上而下约束,数据自下而上流动"机制,通过分层治理和标准化连接,在保证数据主权的同时实现跨域协作,具有策略分级执行、去中心化治理等特性,支持灵活扩展业务场景。

友莘居士的博客 1692

基于LSTM GRU RNN的交通流量预测-完整数据代码

基于LSTM GRU RNN的交通流量预测-完整数据代码

923

Debezium报错处理系列之第112篇:Cannot replicate because the master purged required binary logs. Replicate the

Debezium报错处理系列之第112篇:Cannot replicate because the master purged required binary logs.

zhengzaifeidelushang的博客 729

uniapp微信小程序 - 详解map地图markers图标不显示问题,自定义图标真机调试不显示变成默认marker标记点图标(解决微信小程序map组件markers自定义图标失效,兼容安卓苹果手机)

uniapp微信小程序 map地图markers图标不显示,markers图标真机调试不显示,uniapp map地图显示图标markers问题,自定义图标不显示,添加marker后不显示,uniapp 微信小程序 map marker图标不显示如何解决,uniapp小程序地图的marker图标不显示问题,微信小程序map组件markers自定义图标真机显示问题,uni-app, 微信小程序, map组件, markers图标不显示, 真机调试, 微信小程序map组件,地图加载后marker标记点ios设备

🏆 前端领域优质创作者 2919

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

上一篇: ZedGraph库里属性介绍(4)AxisLabel
下一篇: 使用MiniExcel.SaveAsByTemplate快速地保存百万数据
caimouse
caimouse 优质创作者: 人工智能技术领域 优质创作者: 人工智能技术领域 领域专家: Python技术领域 领域专家: Python技术领域
博客等级 码龄25年 1万+粉丝 3557原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

caimouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值