刚刚安装了material-table,一个基于 material-ui 的表格组件的框架。
这是我在控制台和终端中得到的:
我试图做的是从我找到的解决方案中安装不同版本的 babel、babel-core、babel-loader。
我不知道这是否是问题,错误似乎对我说。
这与 package.json 相关:
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"webpack": "^4.38.0",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2"
我在应用程序中拥有的其他 React 组件不会发生此问题;
他们提供的“入门”组件会发生这种情况:
import MaterialTable from "material-table";
class ListNew extends Component {
render() {
return (
<div style={{ maxWidth: "100%" }}>
<MaterialTable
columns={[
{ title: "Adı", field: "name" },
{ title: "Soyadı", field: "surname" },
{ title: "Doğum Yılı", field: "birthYear", type: "numeric" },
{
title: "Doğum Yeri",
field: "birthCity",
lookup: { 34: "İstanbul", 63: "Şanlıurfa" }
}
]}
data={[
{ name: "Mehmet", surname: "Baran", birthYear: 1987, birthCity: 63 }
]}
title="Demo Title"
/>
</div>
);
}
}
export default ListNew;
网络包配置:
var path = require("path");
module.exports = {
entry: "./script.js",
output: {
path: path.resolve(__dirname, ""),
filename: "transpiled.js"
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
exclude: "/node_modules/",
query: {
presets: ["es2015", "react"]
}
}
]
}
};