1. layui.use('layer'ction(){
var layer = layui.layer;
layer.msg('hello');
});
2.layer提供了5种层类型,0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层)
若采用layer.open({type: 1})方式调用,则type为必填项(信息框除外)
3. $.post('url', {}, function(str){
layer.open({
type: 1,
content: str //注意,如果str是object,那么需要字符拼接。
});
});
4.//单个使用
layer.open({
skin: 'demo-class'
});
//全局使用。即所有弹出层都默认采用,但是单个配置skin的优先级更高
layer.config({
skin: 'demo-class'
})
5.layer.open({
content: '测试回调',
success: function(layero, index){ //success会携带两个参数,分别是当前层DOM当前层索引
console.log(layero, index);
}
});
6.layer.confirm('is not?', {icon: 3, title:'提示'}, function(index){
//do something
layer.close(index);
});
7.
//嵌套在指定容器中
laydate.render({
elem: '#test2'
,position: 'static'
,change: function(value, date){ //监听日期被切换
lay('#testView').html(value);
}
});
2.Layui实战:弹层交互全攻略
于 2025-06-01 12:11:31 首次发布