タイトルとして。
自分のせい
browser.js?add8:40 Uncaught Invariant Violation: app.model: namespace should be defined
// .babelrc
{
"presets": ["react", "es2015","stage-1"],
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}
var webpack = require('webpack');
module.exports = {
entry: __dirname + "/src/index.js",
output: {
path: __dirname + "/dist",
filename: "index.js"
},
devtool: 'eval-source-map',
devServer: {
contentBase: "./src",
colors: true,
historyApiFallback: true,
inline: true,
// hot: true
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.json$/,
loader: "json"
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel',
},
{
test: /\.(css|less)$/,
loader: 'style!css?modules'
}
]
}
}
用作成-react-app ?
create-react-appをインストールして、アプリを作成します。
$ npm install create-react-app -g
$ create-react-app myapp
プロジェクトディレクトリを入力します。
$ cd myapp
dvaをインストールします。
$ npm install dva --save
src/index.js
を編集し、次のように置き換えます。
import React from 'react';
import dva from 'dva';
import App from './App';
import './index.css';
const app = dva();
app.router(() => <App />);
app.start('#root');
アプリケーションを起動します。
$ npm start
この時点で環境構成が完了し、モデルやルーターなどを追加できます。
同じ問題があります名前空間を定義する必要があります
最も参考になるコメント
create-react-appを使用してdvaアプリケーションを開発する
create-react-appをインストールして、アプリを作成します。
プロジェクトディレクトリを入力します。
dvaをインストールします。
src/index.js
を編集し、次のように置き換えます。アプリケーションを起動します。
この時点で環境構成が完了し、モデルやルーターなどを追加できます。