标签:fse 模拟 for iframe 出图 .config str ima com
layer是一款近年来备受青睐的web弹层组件,她具备全方位的解决方案,致力于服务各水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验。
官网:http://layer.layui.com/
//初体验
//询问框
//提示层
//墨绿深蓝风
//捕获页
//页面层
//自定页
//tips层
//iframe层
//tips层
//iframe层
一个在底部弹出的完整对话框:
layer.open({
title: [
‘我是标题‘,
‘background-color:#8DCE16; color:#fff;‘
]
,anim: ‘up‘
,content: ‘展现的是全部结构‘
,btn: [‘确认‘, ‘取消‘]
});
设置3秒自动关闭:
layer.open({
content: ‘通过style设置你想要的样式‘
,style: ‘background-color:#09C1FF; color:#fff; border:none;‘ //自定风格
,time: 3
});
设置不允许点遮罩关闭:
layer.open({
content: ‘不允许点击遮罩关闭‘,
btn: ‘我知道了‘,
shadeClose: false,
yes: function(){
layer.open({
content: ‘好的‘
,time: 2
,skin: ‘msg‘
});
}
});
自定义一个全屏的页面层:
var pageii = layer.open({
type: 1
,content: html
,anim: ‘up‘
,style: ‘position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;‘
});
//iframe窗
//加载层
//loading层
//小tips
//prompt层
//tab层
//相册层
//信息框-例1
//信息框-例2
//信息框-例3
//信息框-例4
//信息框-例5
//信息框-例4
//信息框-例5 晃动
//页面层-自定义
//加载层-默认风格
//打酱油
//默认prompt
//屏蔽浏览器滚动条
//弹出即全屏
//正上方
//多窗口模式,层叠置顶 layer.open({ type: 2 //此处以iframe举例 ,title: ‘当你选择该窗体时,即会在最顶端‘ ,area: [‘390px‘, ‘330px‘] ,shade: 0 ,offset: [ //为了演示,随机坐标 Math.random()*($(window).height()-300) ,Math.random()*($(window).width()-390) ] ,maxmin: true ,content: ‘settop.html‘ ,btn: [‘继续弹出‘, ‘全部关闭‘] //只是为了演示 ,yes: function(){ $(that).click(); //此处只是为了演示,实际使用可以剔除 } ,btn2: function(){ layer.closeAll(); } ,zIndex: layer.zIndex //重点1 ,success: function(layero){ layer.setTop(layero); //重点2 } });
//配置一个透明的询问框
layer.msg(‘大部分参数都是可以公用的<
br>合理搭配,展示不一样的风格‘,
{ time: 20000, //20s后自动关闭
btn: [‘明白了‘, ‘知道了‘, ‘哦‘] });
//示范一个公告层 layer.open({ type: 1 ,title: false //不显示标题栏 ,closeBtn: false ,area: ‘300px;‘ ,shade: 0.8 ,id: ‘LAY_layuipro‘ //设定一个id,防止重复弹出 ,resize: false ,btn: [‘火速围观‘, ‘残忍拒绝‘] ,btnAlign: ‘c‘ ,moveType: 1 //拖拽模式,0或者1 ,content: ‘<div style="padding: 50px; line-height: 22px; color: #fff; font-weight: 300;">你知道吗?亲!<br>layer ≠ layui<br><br>layer只是作为Layui的一个弹层模块,由于其用户基数较大,所以常常会有人以为layui是layerui<br><br>layer虽然已被 Layui 收编为内置的弹层模块,但仍然会作为一个独立组件全力维护、升级。<br><br>我们此后的征途是星辰大海 ^_^</div>‘ ,success: function(layero){ var btn = layero.find(‘.layui-layer-btn‘); btn.find(‘.layui-layer-btn0‘).attr({ href: ‘http://www.layui.com/‘ ,target: ‘_blank‘ }); } });
制造一个通讯
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="//res.layui.com/layui/build/css/layui.css" media="all">
</head>
<body>
<blockquote class="layui-elem-quote">由于LayIM是我们目前唯一的付费组件,所以在你下载的layui包里,并不包含LayIM。如果你觉得Layui对你有所帮助,并且你希望Layui能够持续发展下去,那么我们很欢迎你能捐赠Layui,成为我们的VIP2+,这对我们的促进将会极大!</blockquote>
<a class="layui-btn layui-btn-normal" href="http://layim.layui.com/" target="_blank">前去LayIM官网</a>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>面板外的操作</legend>
</fieldset>
<div class="site-demo-button">
<button class="layui-btn site-demo-layim" data-type="chat">创造一个临时会话</button>
<button class="layui-btn site-demo-layim" data-type="message">制造一个好友发过来的消息</button>
<button class="layui-btn site-demo-layim" data-type="messageTemp">制造一个临时会话消息</button>
<br>
<button class="layui-btn site-demo-layim" data-type="addFriend">增加一个好友</button>
<button class="layui-btn site-demo-layim" data-type="addGroup">增加一个群组</button>
<button class="layui-btn site-demo-layim" data-type="removeFriend">删除一个好友</button>
<button class="layui-btn site-demo-layim" data-type="removeGroup">删除一个群组</button>
<br>
<style>
.layim-list-gray{-webkit-filter: grayscale(100%); -ms-filter: grayscale(100%); filter: grayscale(100%);}
</style>
<button class="layui-btn site-demo-layim" data-type="setGray">置灰离线好友</button>
<button class="layui-btn site-demo-layim" data-type="unGray">取消好友置灰</button>
<a href="http://layim.layui.com/kefu.html" class="layui-btn site-demo-layim" target="_blank">客服模式</a>
</div>
<script src="//res.layui.com/layui/build/layui.js" charset="utf-8"></script>
<script>
layui.use(‘layim‘, function(){
var layim = layui.layim;
var autoReplay = [
‘您好,我现在有事不在,一会再和您联系。‘,
‘你没发错吧?face[微笑] ‘,
‘洗澡中,请勿打扰,偷窥请购票,个体四十,团体八折,订票电话:一般人我不告诉他!face[哈哈] ‘,
‘你好,我是主人的美女秘书,有什么事就跟我说吧,等他回来我会转告他的。face[心] face[心] face[心] ‘,
‘face[威武] face[威武] face[威武] face[威武] ‘,
‘<(@ ̄︶ ̄@)>‘,
‘你要和我说话?你真的要和我说话?你确定自己想说吗?你一定非说不可吗?那你说吧,这是自动回复。‘,
‘face[黑线] 你慢慢说,别急……‘,
‘(*^__^*) face[嘻嘻] ,是贤心吗?‘
];
//基础配置
layim.config({
//初始化接口
init: {
url: ‘/layim/json/getList.json‘
,data: {}
}
//查看群员接口
,members: {
url: ‘/layim/json/getMembers.json‘
,data: {}
}
,uploadImage: {
url: ‘‘ //(返回的数据格式见下文)
,type: ‘‘ //默认post
}
,uploadFile: {
url: ‘‘ //(返回的数据格式见下文)
,type: ‘‘ //默认post
}
//,skin: [‘aaa.jpg‘] //新增皮肤
//,isfriend: false //是否开启好友
//,isgroup: false //是否开启群组
,chatLog: ‘/layim/demo/chatlog.html‘ //聊天记录地址
,find: ‘/layim/demo/find.html‘
});
//监听发送消息
layim.on(‘sendMessage‘, function(data){
var To = data.to;
//演示自动回复
setTimeout(function(){
var obj = {};
if(To.type === ‘group‘){
obj = {
username: ‘模拟群员‘+(Math.random()*100|0)
,avatar: layui.cache.dir + ‘images/face/‘+ (Math.random()*72|0) + ‘.gif‘
,id: To.id
,type: To.type
,content: autoReplay[Math.random()*9|0]
}
} else {
obj = {
username: To.name
,avatar: To.avatar
,id: To.id
,type: To.type
,content: autoReplay[Math.random()*9|0]
,timestamp: new Date().getTime()
}
}
layim.getMessage(obj);
}, 1000);
//console.log(data);
});
//监听在线状态的切换事件
layim.on(‘online‘, function(data){
//console.log(data);
});
//监听查看群员
layim.on(‘members‘, function(data){
//console.log(data);
});
//监听聊天窗口的切换
layim.on(‘chatChange‘, function(data){
//console.log(data);
});
//面板外的操作
var $ = layui.jquery, active = {
chat: function(){
//创造一个临时会话
layim.chat({
name: ‘小闲‘
,type: ‘friend‘
,avatar: ‘http://tva3.sinaimg.cn/crop.0.0.180.180.180/7f5f6861jw1e8qgp5bmzyj2050050aa8.jpg‘
,id: 1008612
});
layer.msg(‘也就是说,此人可以不在好友面板里‘);
}
,message: function(){
//制造一个好友发过来的消息
layim.getMessage({
username: "贤心"
,avatar: "http://tp1.sinaimg.cn/1571889140/180/40030060651/1"
,id: "100001"
,type: "friend"
,content: "嗨,你好!欢迎体验LayIM。演示标记:"+ new Date().getTime()
,timestamp: new Date().getTime()
});
}
,messageTemp: function(){
//制造一个临时会话消息
layim.getMessage({
username: "小酱"
,avatar: "http://tva1.sinaimg.cn/crop.7.0.736.736.50/bd986d61jw8f5x8bqtp00j20ku0kgabx.jpg"
,id: "198909151014"
,type: "friend"
,content: "临时:"+ new Date().getTime()
});
}
,addFriend: function(){
layer.msg(‘已成功把[冲田杏梨]添加到好友【网红】组里‘, {
icon: 1
});
//增加一个好友
layim.addList({
type: ‘friend‘
,avatar: "http://tp2.sinaimg.cn/2386568184/180/40050524279/0"
,username: ‘冲田杏梨‘
,groupid: 2
,id: "1233333312121212"
,remark: "本人冲田杏梨将结束***的工作"
});
}
,addGroup: function(){
layer.msg(‘已成功把[Angular开发]添加到群组里‘, {
icon: 1
});
//增加一个群组
layim.addList({
type: ‘group‘
,avatar: "http://tva3.sinaimg.cn/crop.64.106.361.361.50/7181dbb3jw8evfbtem8edj20ci0dpq3a.jpg"
,groupname: ‘Angular开发‘
,id: "12333333"
,members: 0
});
}
,removeFriend: function(){
layer.msg(‘已成功删除[凤姐]‘, {
icon: 1
});
//删除一个好友
layim.removeList({
id: 121286
,type: ‘friend‘
});
}
,removeGroup: function(){
layer.msg(‘已成功删除[前端群]‘, {
icon: 1
});
//删除一个群组
layim.removeList({
id: 101
,type: ‘group‘
});
}
//置灰离线好友
,setGray: function(){
var setListGray = function(type, id){
$(‘#layim-‘+type+‘‘+id).addClass(‘layim-list-gray‘);
};
setListGray(‘friend‘, 168168); //friend是固定的,第二个参数为好友id
layer.msg(‘已成功将好友[马小云]置灰‘, {
icon: 1
});
}
//取消好友置灰
,unGray: function(){
var unListGray = function(type, id){
$(‘#layim-‘+type+‘‘+id).removeClass(‘layim-list-gray‘);
};
unListGray(‘friend‘, 168168); //friend是固定的,第二个参数为好友id
layer.msg(‘成功取消好友[马小云]置灰状态‘, {
icon: 1
});
}
};
$(‘.site-demo-layim‘).on(‘click‘, function(){
var type = $(this).data(‘type‘);
active[type] ? active[type].call(this) : ‘‘;
});
});
</script>
</body>
</html>
多功能分页
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="//res.layui.com/layui/build/css/layui.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>开门见山 : 默认分页</legend>
</fieldset>
<div id="demo1"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>自定义主题 : 赤橙黄绿青蓝紫 神马的,随便设:-O</legend>
</fieldset>
<div id="demo2"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>自定义文本 : 上一页、下一页、首页、末页统统被替换</legend>
</fieldset>
<div id="demo3"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>不显示首页、末页</legend>
</fieldset>
<div id="demo4"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>开启 URL hash</legend>
</fieldset>
<div id="demo5"></div>
<blockquote class="layui-elem-quote">
切换分页后看地址栏的变化(#后面的fenye名字可以随便定义),该功能对于单页应用有着极大的帮助
</blockquote>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>只显示上一页、下一页</legend>
</fieldset>
<div id="demo6"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>是时候看一下完整功能了!</legend>
</fieldset>
<div id="demo7"></div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>将一段已知数组分页展示</legend>
</fieldset>
<div id="demo8"></div>
<ul id="biuuu_city_list"></ul>
<script src="//res.layui.com/layui/build/layui.js" charset="utf-8"></script>
<script>
layui.use([‘laypage‘, ‘layer‘], function(){
var laypage = layui.laypage
,layer = layui.layer;
laypage({
cont: ‘demo1‘
,pages: 100 //总页数
,groups: 5 //连续显示分页数
});
laypage({
cont: ‘demo2‘
,pages: 100
,skin: ‘#1E9FFF‘
});
laypage({
cont: ‘demo3‘
,pages: 100
,first: 1
,last: 100
,prev: ‘<em><</em>‘
,next: ‘<em>></em>‘
});
laypage({
cont: ‘demo4‘
,pages: 100
,first: false
,last: false
});
laypage({
cont: ‘demo5‘
,pages: 100
,curr: location.hash.replace(‘#!fenye=‘, ‘‘) //获取hash值为fenye的当前页
,hash: ‘fenye‘ //自定义hash值
});
laypage({
cont: ‘demo6‘
,pages: 5
,groups: 0
,first: false
,last: false
,jump: function(obj, first){
if(!first){
layer.msg(‘第 ‘+ obj.curr +‘ 页‘);
}
}
});
laypage({
cont: ‘demo7‘
,pages: 100
,skip: true
});
//将一段数组分页展示
//测试数据
var data = [
‘北京‘,
‘上海‘,
‘广州‘,
‘深圳‘,
‘杭州‘,
‘长沙‘,
‘合肥‘,
‘宁夏‘,
‘成都‘,
‘西安‘,
‘南昌‘,
‘上饶‘,
‘沈阳‘,
‘济南‘,
‘厦门‘,
‘福州‘,
‘九江‘,
‘宜春‘,
‘赣州‘,
‘宁波‘,
‘绍兴‘,
‘无锡‘,
‘苏州‘,
‘徐州‘,
‘东莞‘,
‘佛山‘,
‘中山‘,
‘成都‘,
‘武汉‘,
‘青岛‘,
‘天津‘,
‘重庆‘,
‘南京‘,
‘九江‘,
‘香港‘,
‘澳门‘,
‘台北‘
];
var nums = 5; //每页出现的数据量
//模拟渲染
var render = function(curr){
//此处只是演示,实际场景通常是返回已经当前页已经分组好的数据
var str = ‘‘, last = curr*nums - 1;
last = last >= data.length ? (data.length-1) : last;
for(var i = (curr*nums - nums); i <= last; i++){
str += ‘<li>‘+ data[i] +‘</li>‘;
}
return str;
};
//调用分页
laypage({
cont: ‘demo8‘
,pages: Math.ceil(data.length/nums) //得到总页数
,jump: function(obj){
document.getElementById(‘biuuu_city_list‘).innerHTML = render(obj.curr);
}
});
});
</script>
</body>
</html>
文件上传
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="//res.layui.com/layui/build/css/layui.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>设定上传文件的格式</legend>
</fieldset>
<input name="file" class="layui-upload-file" type="file">
<input name="file1" lay-type="file" class="layui-upload-file" type="file">
<input name="file1" lay-type="audio" class="layui-upload-file" type="file">
<input name="file2" lay-type="video" class="layui-upload-file" type="file">
<blockquote class="layui-elem-quote" style="margin-top: 20px;">支持拖动文件上传</blockquote>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>演示上传</legend>
</fieldset>
<div class="site-demo-upload">
<img id="LAY_demo_upload" src="http://layer.layui.com/images/tong.jpg">
<div class="site-demo-upbar">
<input name="file" class="layui-upload-file" id="test" type="file">
</div>
</div>
<p style="margin-top: 20px;">注:由于服务器资源有限,所以此处每次给你返回的是同一张图片</p>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>自定义文本</legend>
</fieldset>
<input name="file" class="layui-upload-file" lay-title="添加一个碉堡了的图片" type="file">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>保留原始风格</legend>
</fieldset>
<input name="file" type="file">
<blockquote class="layui-elem-quote" style="margin-top: 20px;">即不改变input的样式,只提供上传功能</blockquote>
<script src="//res.layui.com/layui/build/layui.js" charset="utf-8"></script>
<script>
layui.use(‘upload‘, function(){
layui.upload({
url: ‘‘ //上传接口
,success: function(res){ //上传成功后的回调
console.log(res)
}
});
layui.upload({
url: ‘/test/upload.json‘
,elem: ‘#test‘ //指定原始元素,默认直接查找class="layui-upload-file"
,method: ‘get‘ //上传接口的http类型
,success: function(res){
LAY_demo_upload.src = res.url;
}
});
});
</script>
</body>
</html>
表单验证
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="//res.layui.com/layui/build/css/layui.css" media="all">
</head>
<body>
<blockquote class="layui-elem-quote">
鉴于小伙伴的普遍反馈,先温馨提醒两个常见“问题”:1. <a href="http://www.layui.com/doc/base/faq.html#form" target="_blank">为什么select/checkbox/radio没显示?</a> 2. <a href="http://www.layui.com/doc/modules/form.html#render" target="_blank">动态添加的表单元素如何更新?</a>
</blockquote>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
<legend>响应式的表单集合</legend>
</fieldset>
<form class="layui-form" action="">
<div class="layui-form-item">
<label class="layui-form-label">单行输入框</label>
<div class="layui-input-block">
<input name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">验证必填项</label>
<div class="layui-input-block">
<input name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">验证手机</label>
<div class="layui-input-inline">
<input name="phone" lay-verify="phone" autocomplete="off" class="layui-input" type="tel">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">验证邮箱</label>
<div class="layui-input-inline">
<input name="email" lay-verify="email" autocomplete="off" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">验证数字</label>
<div class="layui-input-inline">
<input name="number" lay-verify="number" autocomplete="off" class="layui-input" type="number">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">验证日期</label>
<div class="layui-input-block">
<input name="date" id="date" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" type="text">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">验证链接</label>
<div class="layui-input-block">
<input name="url" lay-verify="url" autocomplete="off" class="layui-input" type="tel">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">验证身份证</label>
<div class="layui-input-block">
<input name="identity" lay-verify="identity" placeholder="" autocomplete="off" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">自定义验证</label>
<div class="layui-input-inline">
<input name="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input" type="password">
</div>
<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">范围</label>
<div class="layui-input-inline" style="width: 100px;">
<input name="price_min" placeholder="¥" autocomplete="off" class="layui-input" type="text">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline" style="width: 100px;">
<input name="price_max" placeholder="¥" autocomplete="off" class="layui-input" type="text">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单行选择框</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1" selected="">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">分组选择框</label>
<div class="layui-input-inline">
<select name="quiz">
<option value="">请选择问题</option>
<optgroup label="城市记忆">
<option value="你工作的第一个城市">你工作的第一个城市</option>
</optgroup>
<optgroup label="学生时代">
<option value="你的工号">你的工号</option>
<option value="你最喜欢的老师">你最喜欢的老师</option>
</optgroup>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">行内选择框</label>
<div class="layui-input-inline">
<select name="quiz1">
<option value="">请选择省</option>
<option value="浙江" selected="">浙江省</option>
<option value="你的工号">江西省</option>
<option value="你最喜欢的老师">福建省</option>
</select>
</div>
<div class="layui-input-inline">
<select name="quiz2">
<option value="">请选择市</option>
<option value="杭州">杭州</option>
<option value="宁波" disabled="">宁波</option>
<option value="温州">温州</option>
<option value="温州">台州</option>
<option value="温州">绍兴</option>
</select>
</div>
<div class="layui-input-inline">
<select name="quiz3">
<option value="">请选择县/区</option>
<option value="西湖区">西湖区</option>
<option value="余杭区">余杭区</option>
<option value="拱墅区">临安市</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">复选框</label>
<div class="layui-input-block">
<input name="like[write]" title="写作" type="checkbox">
<input name="like[read]" title="阅读" checked="" type="checkbox">
<input name="like[game]" title="游戏" type="checkbox">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">开关-关</label>
<div class="layui-input-block">
<input name="close" lay-skin="switch" title="开关" type="checkbox">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">开关-开</label>
<div class="layui-input-block">
<input checked="" name="open" lay-skin="switch" lay-filter="switchTest" title="开关" type="checkbox">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input name="sex" value="男" title="男" checked="" type="radio">
<input name="sex" value="女" title="女" type="radio">
<input name="sex" value="禁" title="禁用" disabled="" type="radio">
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">普通文本域</label>
<div class="layui-input-block">
<textarea placeholder="请输入内容" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">编辑器</label>
<div class="layui-input-block">
<textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor"></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</div>
</form>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>方框风格的表单集合</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="">
<div class="layui-form-item">
<label class="layui-form-label">长输入框</label>
<div class="layui-input-block">
<input name="title" autocomplete="off" placeholder="请输入标题" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">短输入框</label>
<div class="layui-input-inline">
<input name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">日期选择</label>
<div class="layui-input-block">
<input name="date" id="date" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" type="text">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">行内表单</label>
<div class="layui-input-inline">
<input name="number" autocomplete="off" class="layui-input" type="number">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-inline">
<input name="password" placeholder="请输入密码" autocomplete="off" class="layui-input" type="password">
</div>
<div class="layui-form-mid layui-word-aux">请务必填写用户名</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">范围</label>
<div class="layui-input-inline" style="width: 100px;">
<input name="price_min" placeholder="¥" autocomplete="off" class="layui-input" type="text">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline" style="width: 100px;">
<input name="price_max" placeholder="¥" autocomplete="off" class="layui-input" type="text">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单行选择框</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1" selected="">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">行内选择框</label>
<div class="layui-input-inline">
<select name="quiz1">
<option value="">请选择省</option>
<option value="浙江" selected="">浙江省</option>
<option value="你的工号">江西省</option>
<option value="你最喜欢的老师">福建省</option>
</select>
</div>
<div class="layui-input-inline">
<select name="quiz2">
<option value="">请选择市</option>
<option value="杭州">杭州</option>
<option value="宁波" disabled="">宁波</option>
<option value="温州">温州</option>
<option value="温州">台州</option>
<option value="温州">绍兴</option>
</select>
</div>
<div class="layui-input-inline">
<select name="quiz3">
<option value="">请选择县/区</option>
<option value="西湖区">西湖区</option>
<option value="余杭区">余杭区</option>
<option value="拱墅区">临安市</option>
</select>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">文本域</label>
<div class="layui-input-block">
<textarea placeholder="请输入内容" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="demo2">跳转式提交</button>
</div>
</form>
<script src="//res.layui.com/layui/build/layui.js" charset="utf-8"></script>
<script>
layui.use([‘form‘, ‘layedit‘, ‘laydate‘], function(){
var form = layui.form()
,layer = layui.layer
,layedit = layui.layedit
,laydate = layui.laydate;
//创建一个编辑器
var editIndex = layedit.build(‘LAY_demo_editor‘);
//自定义验证规则
form.verify({
title: function(value){
if(value.length < 5){
return ‘标题至少得5个字符啊‘;
}
}
,pass: [/(.+){6,12}$/, ‘密码必须6到12位‘]
,content: function(value){
layedit.sync(editIndex);
}
});
//监听提交
form.on(‘submit(demo1)‘, function(data){
layer.alert(JSON.stringify(data.field), {
title: ‘最终的提交信息‘
})
return false;
});
});
</script>
</body>
</html>
标签:fse 模拟 for iframe 出图 .config str ima com
原文地址:http://www.cnblogs.com/bk-sl/p/6127013.html