问题描述
我正在尝试构建一个 ReactDataGrid 组件。组件的 jsx 文件复制自数据网格的网站示例:
: React.FC<SearchInputProps>
import React from 'react';
import ReactDataGrid from 'react-data-grid';
const columns = [
{ key: 'id',name: 'ID' },{ key: 'title',name: 'Title' },{ key: 'count',name: 'Count' } ];
const rows = [{id: 0,title: 'row1',count: 20},{id: 1,count: 40},{id: 2,count: 60}];
function HelloWorld() {
return (<ReactDataGrid
rows={}
columns={columns}
rowGetter={i => rows[i]}
rowsCount={3}
minHeight={150} />);
}
当我从命令行运行“npm run build”时,收到以下错误:
const path = require('path');
module.exports = {
entry: './src/index.js',output: {
filename: './reader/static/worklist.js',path: path.resolve(__dirname,'dist'),},module: {
rules: [
{
test: /\.(js | \.jsx)$/,loader: "babel-loader",exclude: ['/node_modules/','/public/'],}
]
}
};
有人可以帮我吗?我是转译和反应的新手。
谢谢!
解决方法
问题是正则表达式的语法。而不是:
test: /\.(js | \.jsx)$/,
应该是:
test: /\.(js|jsx)$/,