基于layui的组件,layMin实现的是提示框和预览图片、加载效果等
其实下载的项目包里面有index.html预览例子的
DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>title>
<link rel="stylesheet" href="layui/css/layui.css" />
<style>
#box-load{
width: 200px;
height: 200px;
background: #7fbcf1;
border-radius: 5px;
margin-left: 10px;
margin-top: 10px;
position: relative;
}
style>
head>
<body>
<div id="box-load">div>
<div style="padding: 20px;">
<a class="layui-btn layui-btn-primary" id="lookImg">预览图片a>
<hr />
<a class="layui-btn" id="submit">立即提交a>
<a class="layui-btn layui-btn-primary" onclick="openTips(1)">成功提示a>
<a class="layui-btn layui-btn-primary" onclick="openTips(2)">失败提示a>
<a class="layui-btn layui-btn-primary" onclick="openTips(3)">异常提示a>
div>
body>
<script type="text/javascript" src="layui/layui.js" >script>
<script>
var layMin, $;
/** 引入组件*/
layui.config({
base: "layMin/" // 包
}).extend({
layMin: "layMin" // 组件js
});
layui.use(['layMin', 'jquery'], function(){
// 上面引入组件,这里引入使用
layMin = layui.layMin;
$ = layui.jquery;
var index ;
// 默认
layMin.tips({msg: "操作成功1"});
// 头部提示
layMin.tips({elem: "body", msg: "操作成功", offset: 'top'});
// 模拟手动关闭
var index = layMin.tips({elem: "body", msg: "操作成功2", offset: 'top'});
setTimeout(function(){
layMin.close(index);
// 容器加载中
var index2 = layMin.load({elem: "#box-load", bg: 'white'});
}, 3000)
// 自动关闭
layMin.tips({elem: "body", msg: "操作成功3", offset: 'top', time: 3});
// 自动关闭-开启倒计时线条
layMin.tips({elem: "body", msg: "张三获得勋章", offset: 'right', line: true, time: 10, icon: '', color: '#eb7036'});
// 自动关闭-开启倒计时线条
layMin.tips({elem: "body", msg: "李四获取荣誉", offset: 'right', timeDesc: true, time: 10, icon: '', color: '#eb7036'});
// 自动关闭-开启倒计时线条
layMin.tips({elem: "body", msg: "您有一条消息未处理", offset: 'right', timeDesc: true, line: true, time: 30, icon: '', color: '#eb7036', click: function(){
layMin.tips({elem: "body", msg: "点击成功", offset: 'top', time: 3});
}});
// 预览图片
$("#lookImg").click(function(){
layMin.photo({src: 'img/1.jpg'});
})
// 开始提交
$("#submit").click(function(){
layMin.loadSubmit({elem: '#submit', msg: '正在提交'});
setTimeout(function(){
layMin.closeSubmit({elem: '#submit', msg: '立即提交'});
layMin.tips({elem: "body", msg: "提交成功", offset: 'top', time: 3});
}, 3000)
})
})
var count = 0;
function openTips(value){
count ++;
var offset = 'right';
var line = false;
if(count > 12){
count = 0;
}
if(count > 6){
offset = 'top';
}
var m = Math.floor(Math.random()*8);
if(m%2 == 0){
line = true;
}
if(value == 1){
layMin.tips({elem: "body", msg: "添加成功", stype: 1, offset: offset, line: line, time: 5});
}else if(value == 2){
layMin.tips({elem: "body", msg: "参数错误", stype: 1, offset: offset, line: line, time: 5});
}else{
layMin.tips({elem: "body", msg: "系统异常", stype: 2, offset: offset, line: line, time: 5});
}
}
script>
html>
需注意事项:如果图标不喜欢可以改layMin.js的class“all-icon”
gitee路径下载:https://gitee.com/yuanyongqiang/lay-min
本站免费下载:https://download.csdn.net/download/weixin_43992507/86402685