React / Webpack组件没有显示,出现了什么问题

时间:2016-03-23 17:54:15

标签: javascript reactjs webpack

这是全新的,毫无疑问我做了一些愚蠢的事情,但我有一个我无法展示的组件。

这是我的webpack.config.js

var path = require('path');
var webpack = require('webpack');
var bootstratp = require('react-bootstrap');

module.exports = {
  devtool: 'eval',
  entry: [
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
    './src/index',
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    //path: 'build',
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  resolve:{
    extensions:['','.js','.jsx']
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ],
  module: {
    loaders: [{
      test: /\.js$/,
      loaders: ['react-hot', 'babel'],
      include: path.join(__dirname, 'src')
    }]
  }
};

这是index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

这是App.js

import React, { Component } from 'react';
import {Button} from 'react-bootstrap';

import TestBox from './components/test';
var path = require('path');

export default class App extends Component {

  render() {
    return (
      <div>
        <h1>aaa</h1>
        <TestBox/>
      </div>
    );
  }
}

最后这里是没有出现的组件:

export default
TestBox = React.createClass({
  render:function(){
    return <div>ABCD</div>
  }
});

1 个答案:

答案 0 :(得分:0)

您不需要在导出默认值前加上等号:

尝试这个,类似于你在App.js中的方式:

m = cm.ScalarMappable(cmap=cm.jet)
m.set_array(xxx)
pyplot.colorbar(m)
pyplot.show()