table动态添加一行最多只能添加10行

提问 已结
4 384
小白心
小白心 2018-10-9
悬赏:20飞吻
版本:layui 2.4.3 浏览器:360
点击按钮添加一行数据,最多只能添加10行,就再也添加不了了

各位帮我看看是啥问题[太开心]

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>table</title>
<link rel="stylesheet" href="./layui/css/layui.css" media="all">
</head>
<body>

<table id="demo" lay-filter="test"></table>
<button class="layui-btn layui-btn-lg layui-btn-primary layui-btn-radius" id="btn" onclick="addlist()">添加数据</button>
<script src="./layui/layui.js"></script>
<script>
layui.use('table', function(){
var table = layui.table;

table.render({
elem: '#demo'
,height: 312
,data:[{"id":"1","username":"白心","sex":"男","city":"guangzhou","sign":"kkkkkkkk","experience":"90","score":"90","classify":"程序员","wealth":"10元"}]
,page: true
,cols: [[
{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
,{field: 'username', title: '用户名', width:80}
,{field: 'sex', title: '性别', width:80, sort: true}
,{field: 'city', title: '城市', width:80}
,{field: 'sign', title: '签名', width: 177}
,{field: 'experience', title: '积分', width: 80, sort: true}
,{field: 'score', title: '评分', width: 80, sort: true}
,{field: 'classify', title: '职业', width: 80}
,{field: 'wealth', title: '财富', width: 135, sort: true}
]]
});

});

document.getElementById('btn').addEventListener('click',function () {
var table = layui.table;
var oldData = table.cache["demo"];
var data1={"id":"1","username":"白心","sex":"男","city":"guangzhou","sign":"kkkkkkkk","experience":"90","score":"90","classify":"程序员","wealth":"10元"};
oldData.push(data1);
table.reload('demo',{data : oldData});
});



</script>
</body>
</html>
回帖