我的js代碼如下:import React from 'react';import ReactDOM from "react-dom";import reqwest from 'reqwest';import {Table} from 'antd';? ? const columns = [{? ? ? title:'id',? ? ? dataIndex:'id',? ? ? key:'1'? ? },{? ? ? title:'姓名',? ? ? dataIndex:'name',? ? ? key:'2'? ? },{? ? ? title:'性別',? ? ? dataIndex:'gender',? ? ? key:'3'? ? },{? ? ? title:'生日',? ? ? dataIndex:'birthday',? ? ? key:'4'? ? },{? ? ? title:'籍貫',? ? ? dataIndex:'origo',? ? ? key:'5'? ? },{? ? ? title:'職責',? ? ? dataIndex:'duty',? ? ? key:'6'? ? },{? ? ? title:'圖像',? ? ? dataIndex:'url',? ? ? key:'7'? ? },{? ? ? title:'userId',? ? ? dataIndex:'userId',? ? ? key:'8'? ? }];? ? const Test = React.createClass({? ? ? ? render() {? ? ? ? ? const datas=[];? ? ? ? ? reqwest({? ? ? ? ? ? url: 'http://172.30.140.113:8080/person',? ? ? ? ? ? method: 'get',? ? ? ? ? ? type: 'json',? ? ? ? ? }).then((data) => {? ? ? ? ? ? console.log(data);//這里在控制臺可以顯示數據的? ? ? ? ? ? for(let i=0;i<data.length;i++){? ? ? ? ? ? ? ? datas.push({? ? ? ? ? ? ? ? key:i+1,? ? ? ? ? ? ? ? id:data[i].id,? ? ? ? ? ? ? ? name:data[i].name,? ? ? ? ? ? ? ? url:data[i].avatar,? ? ? ? ? ? ? ? gender:data[i].gender,? ? ? ? ? ? ? ? birthday:data[i].birthday,? ? ? ? ? ? ? ? origo:data[i].origo,? ? ? ? ? ? ? ? duty:data[i].duty,? ? ? ? ? ? ? ? userId:data[i].userId? ? ? ? ? ? ? });? ? ? ? ? ? }? ? ? ? ? ? console.log(datas);//同樣這里在控制臺也是可以顯示數據的? ? ? ? ? });? ? ? ? return (? ? ? ? ? <Table bordered columns={columns}? ? ? ? ? ? dataSource={datas}/>? ? ? ? );? ? ? },? ? });? ? ReactDOM.render(<Test />, document.getElementById('root'));最終在瀏覽器中顯示的結果是:首先是我的代碼編譯沒有出錯的,可以連接到后端端口顯示數據的,在控制臺那里可以看到顯示的數據,但不知道為什么用antd的Table就顯示不出來,可以幫幫我解決嗎?
我想問一下為什么我調用后端的接口,但在瀏覽器中顯示不出來數據,是可以在控制臺中顯示出來的
慕碼人1183263
2016-12-16 16:47:03