Skip to content

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

@fengxinming

Description

@fengxinming

使用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做同样的处理?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions