我正在liferay 7中构建一个npm-react portlet,并且尝试使用https://react-table.js.org来呈现表数据。当我尝试使用浏览器访问portlet时,在以下屏幕截图中出现错误:
MyJS文件:
import React from 'react';
import ReactDOM from 'react-dom';
import Clock from './components/Clock'
import ReactTable from "react-table";
import 'react-table/react-table.css'
function Mytable() {
const data = [{
name: 'Tanner Linsley',
age: 26,
friend: {
name: 'Jason Maurer',
age: 23,
}
}];
const columns = [{
Header: 'Name',
accessor: 'name' // String-based value accessors!
}, {
Header: 'Age',
accessor: 'age',
Cell: props => <span className='number'>{props.value}</span> // Custom cell components!
}, {
id: 'friendName', // Required because our accessor is not a string
Header: 'Friend Name',
accessor: d => d.friend.name // Custom value accessors!
}, {
Header: props => <span>Friend Age</span>, // Custom header components!
accessor: 'friend.age'
}];
return (<ReactTable
data={data}
columns={columns}
/>);
}
export default function (elementId) {
console.log("default");
ReactDOM.render(<Mytable/>, document.getElementById(elementId));
}