Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不用dora怎么配开发环境 #58

Closed
itiwll opened this issue Aug 30, 2016 · 4 comments
Closed

不用dora怎么配开发环境 #58

itiwll opened this issue Aug 30, 2016 · 4 comments

Comments

@itiwll
Copy link

itiwll commented Aug 30, 2016

如题。

@itiwll
Copy link
Author

itiwll commented Aug 30, 2016

自己搭的 报错

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'
      }
    ]
  }
}

@sorrycc
Copy link
Member

sorrycc commented Aug 30, 2016

create-react-app?

@sorrycc
Copy link
Member

sorrycc commented Aug 30, 2016

使用 create-react-app 开发 dva 应用

安装 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

到这里,环境配置就完成了,然后你可以添加 model, router 等。

@adminparry
Copy link

我也是同样的问题 namespace should be defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants