前端弹出框组件

前端Vue自定义弹框、自定义弹框内容 alertView showModel popup 组件 随着技术的发展,开发的复杂度也越来越高,传统开发方式将一个系统做成了整块应用,经常出现的情况就是一个小小的改动或者一个小功能的增加可能会引起整体逻辑的修改,造成牵一发而动全身。通过组件化开发,可以有效实现单独开发,单独维护,而且他们之间可以随意的进行组合。大大提升开发效率低,降低维护成本。今天给大家介绍的一款组件:快速实现前端Vue自定义弹框、自定义设置弹框内容alertView popup组件, 附完整源码下载地址:https://ext.dcloud.net.cn/plugin?id=12491。 阅读详情

下面分享一个js 弹出窗, 分 toast , dialog , load 三种弹窗 , 下面用js css 来实现以下:

  • 首先是js代码 | 采用了 es6 的写法
//公共弹窗加载动画

const   DIALOG_TOAST = '1',
        DIALOG_DIALOG = '2',
        DIALOG_LOAD = '3',

class Dialog {

    constructor(type = DIALOG_DIALOG,
                dialogContent = '请求失败',
                wrapClassName = 'common-dialog-wrap',
                dialogWrapClassName = 'common-dialog-content-wrap',
                contentClassName = 'common-dialog-content',
                btnClassName = 'common-btn',
                btnContent = '确定') {


        this.type = type;

        //吐司
        if (type == DIALOG_TOAST) {
            this.dialog = document.createElement('div');
            this.dialog.className = 'common-toast';
            this.dialog.innerHTML = dialogContent;

        }
        //加载动画
        else if (type == DIALOG_LOAD) {
            this.dialog = document.createElement('div');
            this.dialog.className = wrapClassName;
            this.figure = document.createElement('figure');
            this.figure.className = 'common-loadGif';
            this.img = document.createElement('img');
            this.img.src = getAbsolutePath() + '/fenqihui/static/bitmap/travel/loadgif.gif';
            this.figure.appendChild(this.img);
            this.dialog.appendChild(this.figure);

        } else if (type == DIALOG_DIALOG) {
            this.dialog = document.createElement('div');
            this.dialog.className = wrapClassName;
            this.dialogWrap = document.createElement('div');
            this.dialogWrap.className = dialogWrapClassName;
            this.conetent = document.createElement('p');
            this.conetent.innerHTML = dialogContent;
            this.conetent.className = contentClassName;
            this.confirmButton = document.createElement('p');
            this.confirmButton.innerHTML = btnContent;
            this.confirmButton.className = btnClassName;
            this.dialogWrap.appendChild(this.conetent);
            this.dialogWrap.appendChild(this.confirmButton);
            this.dialog.appendChild(this.dialogWrap);
            this.bindEvent();
        }


    }


    bindEvent() {
        this.confirmButton.addEventListener('click', ()=> {
            this.hide();
        })
    }

    show(time) {
        document.querySelector('body').appendChild(this.dialog);
        $(this.dialog).css('display', 'block');

        if (this.type == DIALOG_TOAST) {

            setTimeout(()=> {
                $(this.dialog).css('display', 'none');
            }, time);
        }

    }

    hide() {
        $(this.dialog).css('display', 'none');
    }

}

css 文件如下:

/*公共弹窗*/
.common-dialog-wrap {
    position: fixed;
    background: rgba(0,0,0,.7);
    z-index: 100;
    height: 100%;
    width: 100%;
    top: 0;
}

.common-dialog-content {
    height: 2rem;
    border-bottom: 1px solid #ccc7c7;
    line-height: 2rem;
    text-align: center;
    font-size: .65rem;
}

.common-btn {
    text-align: center;
    height: 2rem;
    color: orange;
    line-height: 2rem;
}

.common-dialog-content-wrap{
    background: #fff;
    width: 10rem;
    height: 4rem;
    border-radius: 5px;
    position: fixed;
    left: 0;
    top:0;
    right: 0;
    bottom: 0;
    margin: auto;
}

/*吐司样式*/
.common-toast{
    height: 1.6rem;
    width: 4rem;
    box-sizing: content-box;
    color: #fff;
    padding: 0 10px;
    position: fixed;
    left: 0;
    top:0;
    bottom: 0;
    right: 0;
    text-align: center;
    line-height: 1.6rem;
    margin: auto;
    background: rgba(0,0,0,.7);
    border-radius: 2rem;
}

.common-loadGif{
    height: 4rem;
    width: 4rem;
    position: fixed;
    top:0;
    left: 0;
    bottom: 0;
    right: 0;
    margin: auto;
}

.common-loadGif img{
    height: 100%;
    width: 100%;
    border-radius: 10px;
}

使用方式

new Dialog(DIALOG_DIALOG).show()   | hide()
new Dialog(DIALOG_LOAD).show()   | hide()
new Dialog(DIALOG_TOAST).show(time : number)   | hide()

效果如下

这里写图片描述

这里写图片描述

加载动画

精美多样的弹出框样式设计与实战应用 打开弹窗 阅读详情

相关推荐

原生js Dialog对话框插件制作19种对话框弹出层拖动

原生js Dialog对话框插件制作19种对话框弹出层拖动

【JavaScript】8.弹出框(Dialog)

最近做项目,用到了弹出框提示信息,就做了个demo,记录总结了一下,对一般的网站来说,弹出框是比较常见的。或是给出用户操作提示,或是通过弹出框打开一个小窗口以提示信息,或是给出错误警示等等。但是由于浏览器自带的弹出窗口alert,confirm,prompt样式比较单调,且不同的浏览器有不同的默认样式设置,所以在日常工作中,给网站做一个自定义的弹出框非常必要。 html部分 Click Me!

返璞归真 2万+

Dialog:无依赖纯js实现的功能强大的页面Dailog弹出框

Dialog 无依赖纯js实现的功能强大的页面Dailog弹出框

JavaScript 练手小技巧:HTML5 的 dialog 标签制作对话框

对话框,在应用中常常用来做(如,登录、删除信息等)。

九天翔龙的技术博客 1万+

最新版谷歌浏览器Axure插件(免翻墙)

本文介绍了在Chrome浏览器无法直接打开Axure导出HTML文件的解决方法。由于国内网络限制无法访问Chrome商店,需手动下载安装AxureRP扩展插件(提供百度网盘下载链接)。安装步骤包括:1)启用开发者模式;2)拖拽CRX文件或加载解压文件夹;3)勾选"允许访问文件网址"。同时还提示若浏览器版本过低可能无法正常运行,并给出了浏览器升级方法。该教程详细说明了从插件安装到浏览器升级的完整解决方案。

OldCat先生 3000

YOLOv8魔改网络后训练全零?别慌,关掉AMP混合精度训练试试

本文探讨了YOLOv8魔改网络后训练出现全零指标的问题,指出AMP混合精度训练与自定义网络结构的不兼容性。通过分析梯度消失现象和AMP工作原理,提供了关闭AMP、调整学习率等解决方案,并建议预防性开发实践以避免类似问题。

weixin_28338005的博客 330

在Vue3+ElementPlus前端中增加表格记录选择的自定义组件,通过结合Popover 弹出框和Input输入框或者按钮选择实现

上次客户过来讨论的时候,说起其旧系统很多字段选择是通过弹出表格选择记录的,希望沿袭这个使用习惯,否则客户对新系统开发可能不适应,问我如何在Vue3+ElementPlus前端中是否可以实现,我说你基于JQuery的都可以实现,那么Vue3上开发肯定没问题的,而且响应会更加丝滑的,于是我就琢磨做一个通用的案例,整合在我的SqlSugar开发框架的Vue3+ElementPlus前端中。既然要弄就弄个通用的自定义表格选择组件,以便在更多的场合下可以使用,通过动态配置表格字段和相关的属性即可显示和选择。

2023年最新地推相关信息 606

xenomai内核解析--嵌入式实时linux概述

Linux系统作为一个GPOS(通用操作系统)发展至今已经非常成熟可靠了,并且由于遵循GPL协议,开放所有系统源代码,非常易于裁剪。更重要的是,与其他开源的GPOS或RTOS相比,Linux系统支持多种处理器、开发板,提供多种软件开发工具,同时Linux系统对网络和图形界面的支持非常出色。显然,选择Linux操作系统在产品的开发周期和成本控制方面都有巨大优势。 虽然Linux系统功能强大、实用性强...

wsg1100 3709

java前端 js弹出框_前端js弹出框组件使用方法

下面分享一个js 弹出窗, 分 toast , dialog , load 三种弹窗 , 下面用js css 来实现以下:首先是js代码 | 采用了 es6 的写法//公共弹窗加载动画const DIALOG_TOAST = '1',DIALOG_DIALOG = '2',DIALOG_LOAD = '3',class Dialog {constructor(type = DIALOG_DIALO...

weixin_39956612的博客 378

CAN XL和10Base-T1S全对比:在区域架构中如何选择最适合的车载通信协议?

本文深入对比了CAN XL和10Base-T1S在车载网络架构中的性能差异,通过实测数据和典型应用场景分析,为区域架构设计提供选型指南。重点探讨了带宽、延迟、成本等关键指标,帮助工程师在ADAS传感器部署和车身控制网络优化中做出明智选择。

pear55的博客 602

浅谈迪杰斯特拉(Dijkstra)算法和A*算法原理及实现

迪杰斯特拉(Dijkstra)算法和A*算法的原理及实现。

Guo_Zhanyu 9607

前端Vue组件之仿京东拼多多领取优惠券弹出框popup 可用于电商商品详情领券场景使用

仿京东拼多多领取优惠券弹出框popup组件, 可用于电商商品详情领券场景使用。

chenchuang0128的博客 1247

基于 FPGA 的 CNN 卷积神经网络之池化层 Verilog 实现

池化层是卷积神经网络(CNN)中的关键组件,用于降低特征图的维度,减少计算量和防止过拟合。常见的池化操作包括最大池化和平均池化。FPGA 提供了高效的并行处理能力,可以加速这些操作。池化层在 CNN 中扮演重要角色,通过降低数据维度提升计算效率。在 FPGA 上实现池化层,可以充分利用硬件资源实现高效的并行计算,有助于提高实时应用中的推理速度。

走向CTO的路上... 1261

vue--vant组件库Dialog弹出框

vue–vant组件库Dialog弹出框

kuguhuan的博客 6430

【AI测试必学】DeepSeek API 快速入门:获取 API Key 与调用 API 步骤详解

DeepSeek API 使用与 OpenAI 兼容的格式,可以通过修改配置使用 OpenAI SDK。生成的 API Key 只会显示一次,请妥善保存。注册并登录账号,进入左侧导航栏的。创建 API Key。

blues_C的博客 1万+

PyQt(Python+Qt)学习随笔:PyQt界面派生类构造方法中super方法的使用

老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 在《第15.7节 PyQt入门学习:PyQt5应用构建详细过程介绍》和订阅专栏《第二章、PyQt5应用构建详细过程介绍》中,老猿介绍界面派生类的构造方法如下: class MediaPlayerWin(QtWidgets.QWidget,Ui_UI_PlayerWin): def __i...

老猿Python 2714

封装弹出框组件 vue3

vue3弹出框组件

ping 1733

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

在Vue3&#x2B;ElementPlus前端中增加表格记录选择的自定义组件,通过结合Popover 弹出框和Input输入框或者按钮选择实现

上次客户过来讨论的时候,说起其旧系统很多字段选择是通过弹出表格选择记录的,希望沿袭这个使用习惯,否则客户对新系统开发可能不适应,问我如何在Vue3+ElementPlus前端中是否可以实现,我说你基于JQuery的都可以实现,那么Vue3上开发肯定没问题的,而且响应会更加丝滑的,于是我就琢磨做一个通

cmdos的专栏 102

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

弹出框组件

web弹出框组件http://layer.layui.com/

b452608的专栏 536

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

解决 wujie 微前端框架中,Element UI 和 T Design 等组件库在火狐(Firefox)浏览器环境下 Popper 弹出框显示异常

摘要:本文分析了Wujie框架在火狐浏览器中因JS沙箱隔离导致的兼容性问题,特别是popperjs库中DOM节点类型判断失效的情况。作者开发了一个劫持instanceof操作符的插件,通过代理HTMLElement等内置对象的类型判断来修复该问题。相比官方插件,该方案具有仅针对火狐浏览器生效、默认仅代理HTMLElement对象等优势,避免过度代理可能引发的其他问题。插件通过重写Symbol.hasInstance逻辑,确保跨iframe的DOM节点类型判断能够正确执行。

exxes的博客 235

仿京东拼多多优惠券弹出框popup组件的实践与探索

在前端开发的领域里,随着业务逻辑的日益复杂和技术的不断进步,组件化开发逐渐成为了一种主流的开发模式。组件化不仅提高了开发效率,降低了维护成本,更使得代码复用和模块化管理成为可能。本文将介绍一种仿京东拼多多领取优惠券弹出框popup组件的开发实践,并探讨其在实际应用中的意义与价值。一、组件化开发概述在传统的开发方式中,整个系统往往被构建成一个整块应用,这样的结构使得任何小的改动或功能的增加都可能牵一发而动全身,导致整体逻辑的修改。随着业务复杂性的增加,这种开发方式显然已经无法满足现代前端开发的需求。

chenchuang0128的博客 1057
上一篇: 微信端开发 服务器配置 jssdk 方法调用
下一篇: 用纯js实现悬浮按钮组件
一朵红杏
博客等级 码龄12年 51粉丝 282原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址