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

[babel-plugin-dva-hmr][WARN] can't get router path in #15

Open
fengxinming opened this issue Mar 1, 2018 · 2 comments
Open

[babel-plugin-dva-hmr][WARN] can't get router path in #15

fengxinming opened this issue Mar 1, 2018 · 2 comments

Comments

@fengxinming
Copy link

使用dva-cli手脚架搭建好之后,配置dva-hmr启动之后报警告

Starting the development server...

[babel-plugin-dva-hmr][WARN] can't get router path in D:\demows\demos\erp-admin\client\js\index.js
Compiled successfully!

You can now view Your App in the browser.

  Local:            http://localhost:8000/
  On Your Network:  http://192.168.15.159:8000/

Note that the development build is not optimized.
To create a production build, use npm run build.

页面打开后显示 “ Yay! Welcome to dva! ” 和一张大图


修改index.js文件

app.router(require('./router').default); ==> app.router(require('./router'));

重新编译之后,页面就显示报错,但是控制台的WARN变成了INFO

[babel-plugin-dva-hmr][INFO] got routerPath ./router

这是报错信息

[app.router] router should be function, but got object
▶ 2 stack frames were collapsed.
(anonymous function)
D:/demows/demos/erp-admin/client/js/index.js:12
   9 | 
  10 | (function () {
  11 |   console.log('[HMR] inited with babel-plugin-dva-hmr');
> 12 |   app.router(require('./router'));
  13 |   app.use({
  14 |     onHmr: function onHmr(render) {
  15 |       if (module.hot) {
View compiled
defineProperty.value
D:/demows/demos/erp-admin/client/js/index.js:43
  40 |       }
  41 |     }
  42 |   });
> 43 | })(); // 5. Start
  44 | 
  45 | 
  46 | app.start('#root');
View compiled
▶ 6 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.

是不是dva和dva-hmr没有对default做同样的处理?

@dickeylth
Copy link

import router from './router';
app.router(router);

@mikexfreeze
Copy link

LS的方法没用,同样的问题,只有警告不影响开发,经常出现。

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