2017-10-14 60 views
0

我想用PapaParse顯示來自本地csv的數據。 當我試圖做這個代碼時,我只看到console.log()中的數組。CSV解析到表

renderRows =() => { 
     const myData = require('./data.txt'); 
     papaparse.parse(myData, { 
      download: true, 
      delimiter: '\t', 
      complete: function (results) { 
      console.log(results); 
      const rows = results.data.map((result, index) => (
       <tr key={index}> 
       <td>{result}</td> 
       </tr>)) 
      return (rows); 
      } 
     }); 
     } 
     render() { 
     return (
      <div> 
      This is table 
      <table> 
       {this.renderRows()} 
      </table> 
      </div> 
     ); } 
} 

回答