1

我尝试按照在fluxible connectToStores 示例中使用装饰器模式的说明进行操作

http://fluxible.io/addons/connectToStores.html

@connectToStores([FooStore, BarStore], (context, props) => ({
    foo: context.getStore(FooStore).getFoo(),
    bar: context.getStore(BarStore).getBar()
}))
class Component extends React.Component {
    render() {
        return <div/>;
    }
}
export default Component;

但是,我在 @ 符号上遇到语法错误。我是否必须先配置或加载某些内容才能在我的 Fluxible 应用程序中识别装饰器模式?

我已经尝试使用以下 webpack.config.js 来启用对可变模板的阶段 0 支持,但我收到一条错误消息,说当有多个加载器时我无法声明查询

webpack.config.js

var webpack = require('webpack');
var path = require('path');

var webpackConfig = {
    resolve: {
        extensions: ['', '.js', '.jsx']
    },
    entry: [
        'webpack-dev-server/client?http://localhost:3000',
        'webpack/hot/only-dev-server',
        './client.js'
    ],
    output: {
        path: path.resolve('./build/js'),
        publicPath: '/public/js/',
        filename: 'main.js'
    },
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                loaders: [
                    require.resolve('react-hot-loader'),
                    require.resolve('babel-loader')
                ],
                query: {stage: 0}
            },
            { test: /\.json$/, loader: 'json-loader'}
        ]
    },
    node: {
        setImmediate: false
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin(),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify(process.env.NODE_ENV)
            }
        })
    ],
    devtool: 'eval'
};

module.exports = webpackConfig;
4

1 回答 1

0

您需要设置具有阶段 0 支持的 Babel:http: //babeljs.io/docs/setup/#babel_register

于 2015-11-04T18:47:48.870 回答