table加载后台返回数据不显示

提问 未结 6 77
lanyu22
lanyu22 2020-1-15
悬赏:20飞吻
版本:layui 浏览器:
var aa=[{"name":"张三","age":"29"}];

table.reader({
.......
date:aa

.............


请问这种写法怎么不报错也不显示,一直在那转圈圈
回帖
  • reader? date ? 不是render data吗
    0 回复
  • lanyu22
    2020-1-15
    @逸仙Yixian 我意思是我返回的json字符串,怎么可以当做参数赋值给table
    0 回复
  •  table.render({
    elem: '#demo'
    ,height: 420
    ,data:[{
    "id": 10000,
    "username": "user-0",
    "sex": "女",
    "city": "城-0",
    "sign": "签名-0",
    "experience": 255,
    "logins": 24,
    "wealth": 82830700,
    "classify": "作",
    "score": 57
    }, {
    "id": 10001,
    "username": "user-",
    "sex": "男",
    "city": "城市-1",
    "sign": "签名-1",
    "experience": 884,
    "logins": 58,
    "wealth": 64928690,
    "classify": "词",
    "score": 27
    }, {
    "id": 10002,
    "username": "user-",
    "sex": "女",
    "city": "城市-2",
    "sign": "签名-2",
    "experience": 650,
    "logins": 77,
    "wealth": 6298078,
    "classify": "酱",
    "score": 31
    }, {
    "id": 10003,
    "username": "user-",
    "sex": "女",
    "city": "城市-3",
    "sign": "签名-3",
    "experience": 362,
    "logins": 157,
    "wealth": 37117017,
    "classify": "诗",
    "score": 68
    }, {
    "id": 10004,
    "username": "user-",
    "sex": "男",
    "city": "城市-4",
    "sign": "签名-4",
    "experience": 807,
    "logins": 51,
    "wealth": 76263262,
    "classify": "作",
    "score": 6
    }, {
    "id": 10005,
    "username": "user-5",
    "sex": "女",
    "city": "城市-5",
    "sign": "签名-5",
    "experience": 173,
    "logins": 68,
    "wealth": 60344147,
    "classify": "作",
    "score": 87
    }, {
    "id": 10006,
    "username": "user-",
    "sex": "女",
    "city": "城市-6",
    "sign": "签名-6",
    "experience": 982,
    "logins": 37,
    "wealth": 57768166,
    "classify": "作",
    "score": 34
    }, {
    "id": 10007,
    "username": "user-",
    "sex": "男",
    "city": "城市-7",
    "sign": "签名-7",
    "experience": 727,
    "logins": 150,
    "wealth": 82030578,
    "classify": "作",
    "score": 28
    }, {
    "id": 10008,
    "username": "user-",
    "sex": "男",
    "city": "城市-8",
    "sign": "签名-8",
    "experience": 951,
    "logins": 133,
    "wealth": 16503371,
    "classify": "词",
    "score": 14
    }, {
    "id": 10009,
    "username": "user-",
    "sex": "女",
    "city": "城市-9",
    "sign": "签名-9",
    "experience": 484,
    "logins": 25,
    "wealth": 86801934,
    "classify": "词",
    "score": 75
    }]
    ,title: '用户表'
    ,page: true //开启分页
    ,toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
    ,totalRow: true //开启合计行
    ,cols: [[ //表头
    {type: 'checkbox', fixed: 'left'}
    ,{field: 'id', title: 'ID', width:80, sort: true, fixed: 'left', totalRowText: '合计:'}
    ,{field: 'username', title: '用户名', width:80}
    ,{field: 'experience', title: '积分', width: 90, sort: true, totalRow: true}
    ,{field: 'sex', title: '性别', width:80, sort: true}
    ,{field: 'score', title: '评分', width: 80, sort: true, totalRow: true}
    ,{field: 'city', title: '城市', width:150}
    ,{field: 'sign', title: '签名', width: 200}
    ,{field: 'classify', title: '职业', width: 100}
    ,{field: 'wealth', title: '财富', width: 135, sort: true, totalRow: true}
    ,{fixed: 'right', width: 165, align:'center', toolbar: '#barDemo'}
    ]]
    });
    0 回复
  • 可以是可以,注意格式就行了
    0 回复
  • lanyu22
    2020-1-15
    @逸仙Yixian 额,你这是写死的数据,我是从后台返回的,当做变量赋值进去的,现在不报错也不显示
    0 回复
  • 可能是开头结尾有引号,打个断点看看是不是对的格式
    0 回复