原因:token 过期,重新登陆
解决:
请求携带token
table.render({ elem: '#admin' ,height: 'full-50' ,url: requestUrl+'admin/page' ,toolbar: '#toolbarDemo' ,method:'post' ,contentType:"application/json" ,async: true ,headers: { token : localStorage.token } ,request: { pageName: 'pageNum' //页码的参数名称,默认:page ,limitName: 'pageSize', //每页数据量的参数名,默认:limit } ,defaultToolbar: ['filter', 'exports', 'print', { title: '提示', layEvent: 'LAYTABLE_TIPS', icon: 'layui-icon-tips' }], cols: [[ {field:'admId', width:100, title: 'ID', sort: true} ,{field:'admUser', width:100, title: '账号'} ,{field:'admPsw', width:100, title: '密码'} ,{field:'admName', width:100, title: '用户名'} ,{field:'admSex', width:100, title: '性别', align: "center"} ,{title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"} ]], limits: [5,10, 15, 20], limit: 10, page: true, skin: 'line' });
$.ajax({ type:"post", url: requestUrl+"/app", dataType:"json", ,headers: { token : localStorage.token } contentType:"application/json", data: JSON.stringify(data), success: function(data) { console.log(data) }, });
全局设置