我从 react-toolbox 网站复制了基本的按钮实现,它似乎在 react-toolbox 主题中给出了错误。请参阅屏幕截图以了解错误。
我的 index.js 文件
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from 'react-toolbox/lib/button';
ReactDOM.render(
<Button label="Hello World!" />,
document.getElementById('app')
);
我的 webpack.config.js 文件
var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports = {
entry: __dirname + '/app/index.js',
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
output: {
filename: 'transformed.js',
path: __dirname+'/build'
},
plugins: [HTMLWebpackPluginConfig]
};
和 package.json 文件
{
"name": "react2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-toolbox": "^2.0.0-beta.7"
},
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-preset-react": "^6.23.0",
"html-webpack-plugin": "^2.28.0",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
}
}
我错过了什么吗?因为网站上说的只是npm install --save react-toolbox
,仅此而已。
注意 -npm build
运行良好。npm start
给出错误。
请指导:)