Element UI 源码学习之仿写:自定义 el-button 组件

前言
在前端开发中,UI 组件库是提高开发效率和统一界面风格的重要工具。Element UI 是一款基于 Vue.js 的组件库,提供了丰富的 UI 组件,广泛应用于各种 Web 应用开发中。本文将通过学习 Element UI 源码,以仿写 el-button 组件为例,来深入理解组件的实现原理和设计思路。

实现思路
el-button 组件是 Element UI 中常用的按钮组件,具有多种类型、尺寸和状态。我们将从头开始,逐步实现一个简化版的 el-button 组件,包括基本的样式和交互效果。

组件结构
首先,我们需要定义 el-button 组件的结构。在 HTML 中,按钮通常使用 <button> 元素表示。我们将使用 Vue 组件的方式来实现 el-button,因此需要定义一个包含 <button> 元素的组件。

<template>
  <button class
elementui入门-按钮组件的使用及源码解析 2020-12-26 1. 了解element-ui 网站快速成型工具 和 桌面端组件库 基于vue的一个ui框架,该框架基于vue开发了很多相关组件,方便我们快速开发页面 基于vue开发并且进行了开源 ,element ui 提供的全部都是封装好的组件 2.安装 2.1初始化一个脚手架的项目 vue init webpack element 2.2安装elementui 的依赖 npm i element-ui -S 2.3引入elementui //在main.js中引入ElementUI和它的cs 阅读详情

相关推荐

Vue ElementUI 按钮样式自定义

Vue ElementUI 是一个基于 Vue.js 的组件库,它提供了丰富的组件和样式,方便我们开发用户界面。在使用 ElementUI 的按钮组件时,有时我们需要根据项目需求对按钮的样式进行自定义修改。通过以上步骤,我们可以使用编程的方式对 Vue ElementUI 的按钮样式进行自定义修改。首先引入 ElementUI 库,然后在组件中使用按钮组件,并在样式文件中定义自定义的 CSS 类名或使用作用域样式。接下来,我们可以通过修改 ElementUI 的默认样式来实现按钮样式的自定义。

2301_79326254的博客 812

【白话系列】倍增算法

【序言】         我认为吧,所有能够优化复杂度的算法都是神奇的,所有能够化繁琐为形象的文字都是伟大的。一直觉得倍增算法是个很神奇的东西,所以决定写点东西纪念一下它。但是作为一个非常不称职的OIER,我非常讨厌在看别人的算法解析时整版的i,j,k等我看到鼠标就惯性移到右上角的符号语言,所以我想用最形象的方式来纪念它。 【一】         从前,有一只可爱得不得了的小白兔,它想从

JarjingX 3万+

USB PD快充功率监测仪:高精度嵌入式USB电压电流测量终端

USB供电已从数据接口演进为关键电源总线,尤其在PD快充场景下,工程师亟需对5V–20V宽压范围内的实时电压、电流及瞬时功率进行精准捕获。其底层原理依赖高共模抑制比的高边电流检测与分压采样+ADC数字化处理,结合LDO低噪声供电保障模拟链路精度。该类设备的技术价值在于以低成本实现协议无关的‘电气层可视化’,规避商用ASIC测试仪的黑盒局限,支撑PD充电验证、电源设计调试与教学实验等工程实践。本文介绍的开源USB表即基于N32G430 MCU与INA199电流检测芯片,覆盖USB-C输入/输出双通道监测,具备

weixin_42174098的博客 210

傻瓜式下载、安装CentOS7操作步骤

CentOS7.9下载和安装操作步骤

weixin_45608163的博客 1万+

正直摄影方式的精度估算式_利用BDS数据反演大气可降水量及其精度分析

可降水量(PWV)对中小尺度灾害性天气预报具有指示意义,是降雨强度预报的重要参数之一。自20世纪80、90年代起,国外已经对GPS探测大气可降水量进行了大量研究。国内最早由毛节泰引进并详细介绍了地基GPS反演大气可降水量的方法,近年来发展迅速并取得了一定的成果。随着中国北斗卫星导航系统(BDS)提供服务并不断地建设完善,其已经能够应用到气象学领域,可以获得大气可降水量。文献[11]利用...

weixin_39796752的博客 1246

【Bug已解决】Claude Team Plan 购买席位报错 Payment failed 解决方案

方案适用场景推荐指数检查账单历史状态排查的第一步⭐⭐⭐⭐⭐更换支付方式类型快速尝试是否能绕开问题⭐⭐⭐联系官方支持团队最终解决问题的正规渠道⭐⭐⭐⭐⭐临时过渡方案紧急用人需求的应急处理⭐⭐⭐关注官方修复进度确认属于系统性缺陷的场景⭐⭐⭐⭐Claude Team Plan 增购席位报的问题,社区反馈和实际排查表明很大概率属于平台计费系统在处理按比例分摊费用这类复杂计算链路时的系统性缺陷,而不是用户自身的支付信息填写有误。先排除自身账单历史是否存在异常。

一键难忘的博客 4185

Python 安装 PyTorch(GPU)详细教程

本章教程,介绍如何安装PyTorch GPU版本的具体教程。

猿小白的博客 1639

AIoT 在线工程实训平台案例——智能家居

AIoT 在线工程实训平台案例——智能家居的操作步骤

m0_53608652的博客 1432

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 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")

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

上一篇: AngularJS的核心概念和前端开发
下一篇: 前端设计模式:观察者模式在前端开发中的应用
普通网友
博客等级 码龄3年 28粉丝 10原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值