修改button为input
<input class="layui-btn" type="button" lay-submit lay-filter="add" value="立即提交">
layui.use(["jquery", "element", "form", "layer"], function () { var $ = layui.jquery; var form = layui.form; var layer = layui.layer; form.on("submit(add)", function (data) { console.log(data); $.ajax({ url: 'adminbase', type: 'POST', dataType: 'json', data: {data:data.field}, success:function(e){ layer.msg(e.msg); }, fail:function (error) { layer.msg("网络错误,请重试"); } }); return false; }); })
2.laytable中时间戳格式化为正常时间
{field: "addtime", title: "添加时间", width: 200, templet:function(d) {return util.toDateString(d.addtime*1000,'yyyy-MM-dd HH:mm'); }},
3.关闭layer弹出层
var index = parent.layer.getFrameIndex(window.name); setTimeout(function(){ parent.layer.close(index); }, 500)
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com