1.layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案, 致力于服务各水平段的开发人员,
您的页面会轻松地拥有丰富友好的操作体验。
首先来到layer的官网 http://layer.layui.com/,下载layer文档并放在自己的项目文件中
然后在自己的项目中只需要引入layer.js文件,注意在引用layer.js时首先要引用jQuery文件,否则引用会报错。
来到jQuery的官网进行下载jQuery.js并在项目中引用或者通过在线引用的方式
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="style/layer/layer.js"></script>
这样便引入了layer弹窗,以下是layer部分样式介绍详细请见官网http://layer.layui.com/
layer.alert('见到你真的很高兴', {icon: 6});
layer.msg('你确定你很帅么?', {
time: 0
,btn: ['必须啊', '丑到爆']
,yes: function(index){
layer.close(index);
layer.msg('雅蠛蝶 O.o', {
icon: 6
,btn: ['嗷','嗷','嗷']
});
}
});
layer.msg('这是最常用的吧');
layer.msg('不开心。。', {icon: 5});
layer.msg('玩命卖萌中', function(){
});
layer.open({
type: 1,
title: false,
closeBtn: 0,
shadeClose: true,
skin: 'yourclass',
content: '自定义HTML内容'
});
layer.open({
type: 1,
title: false,
closeBtn: 0,
area: ['auto'],
skin: 'layui-layer-nobg',
shadeClose: true,
content: $('#tong')
});
layer.open({
type: 2,
area: ['700px', '450px'],
fixed: false,
maxmin: true,
content: 'test/iframe.html'
});
layer.open({
type: 2,
title: false,
area: ['630px', '360px'],
shade: 0.8,
closeBtn: 0,
shadeClose: true,
content: '//player.youku.com/embed/XMjY3MzgzODg0'
});
layer.msg('点击任意处关闭');
layer.open({
type: 2,
area: ['360px', '500px'],
skin: 'layui-layer-rim',
content: ['mobile/', 'no']
});
layer.load();
setTimeout(function(){
layer.closeAll('loading');
}, 2000);
layer.load(1);
setTimeout(function(){
layer.closeAll('loading');
}, 2000);
layer.load(2);
setTimeout(function(){
layer.closeAll('loading');
}, 2000);
layer.msg('加载中', {
icon: 16
,shade: 0.01
});
layer.msg('尼玛,打个酱油', {icon: 4});
layer.tips('上', '#id或者.class', {
tips: [1, '#0FA6D8']
});
layer.tips('默认就是向右的', '#id或者.class');
layer.tips('下', '#id或者.class', {
tips: 3
});
layer.tips('左边么么哒', '#id或者.class', {
tips: [4, '#78BA32']
});
layer.tips('不销毁之前的', '#id或者.class', {
tipsMore: true
});
layer.prompt(function(val, index){
layer.msg('得到了'+val);
layer.close(index);
});
layer.open({
content: '浏览器滚动条已锁',
scrollbar: false
});
var index = layer.open({
type: 2,
content: 'http://layim.layui.com',
area: ['320px', '195px'],
maxmin: true
});
layer.full(index);
layer.msg('灵活运用offset', {
offset: 't',
anim: 6
});
layer.msg('Hi');