一、需要添加
- 1、需要排序的字段加上
sort: true
属性
- 2、
table.on('sort(lay-filter的值)', function(obj) {
监听排序点击操作
- 3、php接收参数:
sort_field
,sort_order
实现排序
- 4、实际使用中把数据获取方式
data
写死的,改为 url
接口动态获取
- 5、效果图如下:

二、html代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" v="2.5.6" e="layui"/>
</head>
<body>
<table id="demo" lay-filter="test"></table>
<script type="text/html" id="statusTemplet">
{
{
# if(d.status == 1) {
}}
<button class="layui-btn layui-btn-xs">已通过</button>
{
{
# } else if (d.status == 2) {
}}
<button class="layui-btn layui-btn-danger layui-btn-xs">已驳回</button>
{
{
# } else {
}}
<button class="layui-btn layui-btn-primary layui-btn-xs">待审核</button>
{
{
# } }}
</script>
</body>
<script src="https://www.layuicdn.com/layui/layui.js" v="2.5.6" e="layui.all"></script>
<script type