技术标签: MUI
当用户点击按钮后,需要向服务端提交数据或等待服务端响应时,常常需要提示“正在提交”,并将按钮设置为disabled,避免用户重复点击、重复提交;加载中按钮支持修改 loading状态的文案、显示的icon和icon的位置,如下:
属性名 | 作用 |
---|---|
data-loading-text |
loading 状态显示的文案,默认为: loading |
data-loading-icon |
loading 状态显示的icon,默认为mui-spinner 或mui-spinner mui-spinner-white (根据按钮样式自动识别),为空表示不使用icon |
data-loading-icon-position |
loading 状态显示的icon的位置,支持left/right,默认left |
1、默认,左侧loading图标:
<button type="button" class="mui-btn mui-btn-primary">确认</button>
2、 右侧loading图标,增加data-loading-icon-position="right":
<button type="button" class="mui-btn mui-btn-primary" data-loading-text="提交中" data-loading-icon-position="right">确认</button>
3、 无loading图标,增加data-loading-icon="":
<button type="button" class="mui-btn mui-btn-primary" data-loading-icon="">确认</button>
4、自定义loading图标,增加data-loading-text、data-loading-icon、 data-loading-icon-position三个属性的设置:
<button type="button" class="mui-btn mui-btn-primary" data-loading-text="提交中" data-loading-icon="mui-spinner mui-spinner-custom" data-loading-icon-position="right">确认</button>
5、触发事件,JS如下:
mui(document.body).on('tap', '.mui-btn', function(e) {
mui(this).button('loading');//切换为loading状态
setTimeout(function() {
mui(this).button('reset');//切换为reset状态(即重置为原始的button)
}.bind(this), 2000);
});
6、全部状态展示效果:
源码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--标准mui.css-->
<link rel="stylesheet" href="../css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="../css/app.css" />
<style>
input,
button,
.mui-btn {
margin: 5px 15px 10px 5px;
}
.mui-spinner {
display: inline-block;
width: 24px;
height: 24px;
-webkit-transform-origin: 50%;
transform-origin: 50%;
-webkit-animation: spinner-spin 1s step-end infinite;
animation: spinner-spin 1s step-end infinite;
}
.mui-spinner:after {
display: block;
content: "";
width: 100%;
height: 100%;
background-position: 50%;
background-size: 100%;
background-repeat: no-repeat;
}
.mui-spinner-custom:after {
background-image: url("data:image/svg+xml;charset=utf-8,<svg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><defs><line id='l' x1='60' x2='60' y1='7' y2='27' stroke='red' stroke-width='11' stroke-linecap='round'/></defs><g><use xlink:href='%23l' opacity='.27'/><use xlink:href='%23l' opacity='.27' transform='rotate(30 60,60)'/><use xlink:href='%23l' opacity='.27' transform='rotate(60 60,60)'/><use xlink:href='%23l' opacity='.27' transform='rotate(90 60,60)'/><use xlink:href='%23l' opacity='.27' transform='rotate(120 60,60)'/><use xlink:href='%23l' opacity='.27' transform='rotate(150 60,60)'/><use xlink:href='%23l' opacity='.37' transform='rotate(180 60,60)'/><use xlink:href='%23l' opacity='.46' transform='rotate(210 60,60)'/><use xlink:href='%23l' opacity='.56' transform='rotate(240 60,60)'/><use xlink:href='%23l' opacity='.66' transform='rotate(270 60,60)'/><use xlink:href='%23l' opacity='.75' transform='rotate(300 60,60)'/><use xlink:href='%23l' opacity='.85' transform='rotate(330 60,60)'/></g></svg>");
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">加载中按钮插件</h1>
</header>
<div class="mui-content">
<div class="mui-content-padded">
<p style="margin-bottom: 25px;">当用户点击按钮后,需要向服务端提交数据或等待服务端响应时,
常常需要提示“正在提交”,并将按钮设置为disabled,避免用户重复点击、重复提交;
mui的加载中按钮就实现了类似效果,点击如下按钮体验:</p>
<h5>左侧loading图标:</h5>
<button type="button" class="mui-btn mui-btn-primary">确认</button>
<h5>右侧loading图标:</h5>
<button type="button" class="mui-btn mui-btn-primary" data-loading-text="提交中" data-loading-icon-position="right">确认</button>
<h5>无loading图标:</h5>
<button type="button" class="mui-btn mui-btn-primary" data-loading-icon="">确认</button>
<h5>自定义loading图标:</h5>
<button type="button" class="mui-btn mui-btn-primary" data-loading-text="提交中" data-loading-icon="mui-spinner mui-spinner-custom" data-loading-icon-position="right">确认</button>
<h5>其他button效果</h5>
<button type="button" class="mui-btn">确认</button>
<button type="button" class="mui-btn mui-btn-outlined mui-btn-primary">确认</button>
<button type="button" class="mui-btn mui-btn-primary">
确认
<span class="mui-badge mui-badge-primary">2</span>
</button>
<button type="button" class="mui-btn mui-btn-block mui-btn-primary">确认</button>
</div>
</div>
</body>
<script src="../js/mui.min.js"></script>
<script>
mui.init({
swipeBack: true //启用右滑关闭功能
});
mui(document.body).on('tap', '.mui-btn', function(e) {
mui(this).button('loading');//切换为loading状态
setTimeout(function() {
mui(this).button('reset');//切换为reset状态(即重置为原始的button)
}.bind(this), 2000);
});
</script>
</html>
文章浏览阅读601次。为增进大家对内存的认识,本文将为大家介绍高频率内存的优势。此外,小编还将对虚拟内存加以探讨。我们每天都在同内存打交道,但大家对内存真的了解吗?上篇文章中,我们对服务器内存以及服务器内存技术有所介绍,为增进大家对内存的认识,本文将为大家介绍高频率内存的优势。此外,小编还将对虚拟内存加以探讨。如果你对内存及其相关知识具有兴趣,不妨继续往下阅读哦。一、高频率内存优势由于决定内存性能的核心因素有内存容量、..._服务器内存频率高有什么好处
文章浏览阅读3.6k次,点赞4次,收藏8次。报错内容:解决办法:给组件传入force-use-old-canvas="true"就可以在真机调试里展示了。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。<view style="width:..._html canvas is not defined
文章浏览阅读457次。计算机第一章计算机基础知识多项选择题(有两个或两个以上正确答案)1、下列说法中,正确的是________。A、一个汉字用1个字节表示 B、在微机中,使用最普遍的字符编码是ASCII码C、高级语言程序可以编译为目标程序 D、ASCII码的最高位用作奇偶校验位2、文件型(外壳型)计算机病毒主要感染扩展名为________。A、COM B、BAT C、EXE D、DOC3、..._达成某一任务的指令的会合称为语言
文章浏览阅读232次。说明SceneKit系列文章目录更多iOS相关知识查看github上WeekWeekUpProject本教程将包含以下内容:在SceneKit编辑器中建立基本的3D场景.编程加载并呈现3D场景.建立仿真物理,如何应用力.通过触摸与3D场景中的物体交互.设计并实现基本的碰撞检测.开始开始前,先下载初始项目starter project打开项目,简单查看一下里面都有些..._can knockdown1下载
文章浏览阅读1.3k次。材质和Unity Shader在unity中,需要配合使用材质Material和Unity Shader才能达到需要的效果流程创建一个材质→创建一个Unity Shader,并把它赋给上一步中创建的材质→把材质赋给要渲染的对象→在材质面板中调整Unity Shader的属性,以得到满意的效果Unity中的材质Unity中的材质需要配合一个GameObject的Mesh或者Particle Systen组件来工作,它决定了我们的游戏对象看起来是什么样子的Unity中的Shader为了和前面通用的_unity的扩展sprites的shader
文章浏览阅读3.6k次。最新的Hystrix 依赖都是隶属于netfix下,这样@HystrixCommand 和@EnableHystrixDashboard 才能使用<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netf..._hystrix最新依赖
文章浏览阅读844次。一、QTextCodecQTextCodec类提供了文本编码转换功能。指定字符集对文本进行转换。1.Qt程序中所有要显示到界面上的字符串最好都是用tr()函数;代码如下(示例):QTextCodec::setCoderForTr(QTextCodec::codecForName("UTF-8"));QLabel label;label.setText(QObject::tr("你好,世界!"));2.对于不是要显示到界面上的字符串中如果包含了中文,可以使用QString()进行编码转换。代_qt 将txt文件转换成字符串
文章浏览阅读2k次。error: failed to push some refs to 'https://gitee.com/liyue25/test.git'To https://gitee.com/liyue25/test.githint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository push_the breanch to pull from should be selected
文章浏览阅读94次。写一个自己的rjust函数,创建一个字符串的长度是指定长度,原字符串在新字符串中右对齐,剩下的部分用指定的字符填充。写一个自己的index函数,统计指定列表中指定元素的所有下标,如果列表中没有指定元素返回-1。写一个自己的replace函数,将指定字符串中指定的旧字符串转换成指定的新字符串。编写一个函数,提取指定字符串中所有的字母,然后拼接在一起产生一个新的字符串。写一个自己的endswith函数,判断一个字符串是否已指定的字符串结束。写一个自己的upper函数,将一个字符串中所有的小写字母变成大写字母。._写一个自己的rjust函数,创建一个字符串的长度是指定长度,原字符串在新字符串中右
文章浏览阅读1.3k次。spring自定义全局异常背景学习目标案列背景在springmvc的controller中程序员经常要封装错误对象返回错误,前端显示错误文案。通过spring的异常处理器,来进行自定义异常处理学习目标学习全局异常拦截器处理controller所有的异常的返回封装定义枚举异常码,设计自定义异常案列创建枚举异常码,定义系统异常情况/** * @author tianjz */..._18jzz大全
文章浏览阅读95次。越来越多的人搞爬虫,设计到多线程爬取, 还有一些机器学习的一些模块也需要这玩意, 感觉自己不会逼格不高. 抽时间赶紧玩一玩这东西, 希望提高对软件的认知和归属感,不要太傻.cpu内部架构参考你知道CPU是如何工作的?-视频CPU核心越多越好?你的CPU可能正在养老!你真的了解多核处理器吗?1.双核≠双性能多核不一定会使你的手机或电脑速度更快,但它将提高你的PC的整体性能,这是一个...
文章浏览阅读2k次,点赞5次,收藏18次。本篇博客介绍如何利用XBee模块实现QGC地面站与飞控的通信_xbee实现多机控制