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

umi build后,报model组件undefined #1378

Closed
xwy55555 opened this issue Oct 31, 2018 · 17 comments
Closed

umi build后,报model组件undefined #1378

xwy55555 opened this issue Oct 31, 2018 · 17 comments

Comments

@xwy55555
Copy link

基于umi2.2.1构建的管理系统,约定式路由,umi dev时一切正常
umi build后,报model组件undefined

参考了umi所有的示例,也没搞清楚问题出在哪

请各位大神指导一下

@sorrycc
Copy link
Member

sorrycc commented Oct 31, 2018

请提供可复现仓库。

@xwy55555
Copy link
Author

xwy55555 commented Oct 31, 2018

https://github.com/xwy55555/face_cms.git
仓库如上, 操作如下:

git clone https://github.com/xwy55555/face_cms.git
yarn install
yarn start 

======正常

yarn build
yarn global add serve
serve ./dist

======报错

@xiaohuoni
Copy link
Member

应该是交差使用model的问题

@xwy55555
Copy link
Author

xwy55555 commented Nov 1, 2018

应该是交差使用model的问题

即使删得只剩登录模块,也会报同样的问题,所以不是交差使用model的问题

@xwy55555
Copy link
Author

xwy55555 commented Nov 1, 2018

@sorrycc 麻烦抽空看一下

@xwy55555
Copy link
Author

xwy55555 commented Nov 1, 2018

把动态加载关掉(.umirc.js --》dynamicImport: false)就ok了,所以应该是umi架构在处理动态加载时有bug,我猜呀

@sorrycc
Copy link
Member

sorrycc commented Nov 1, 2018

image

我试了下是这个报错,就是 @xiaohuoni 所说的问题,在 /index 下依赖了 userLogin 的 model。

@sorrycc sorrycc closed this as completed Nov 1, 2018
@sorrycc
Copy link
Member

sorrycc commented Nov 1, 2018

还有一些其他问题,

  1. 检查下 .umi/router.js,这里的路由里包含了一些 components 等路由,需要排除掉
  2. dynamicImport 可以配 dynamicImport: { webpackChunkName: true }

@kennylbj
Copy link

确实存在这种情况,交叉使用在dev模式下可以正常使用,在build后就会出现undefined

@zlllya
Copy link

zlllya commented Dec 11, 2018

确实存在这种情况,交叉使用在dev模式下可以正常使用,在build后就会出现undefined

你好,我想请教一下,如果要交叉使用的话,有什么解决方法吗

@CynthiaNC
Copy link

同样出现这个问题~有人解决了吗?

@CynthiaNC
Copy link

#1483 提到对dynamicImport的设置,不设置这个值就解决了build出来的问题

@kennylbj
Copy link

@zouliang073 应该是个bug,不知道修复了没,我当时是的做法是放弃交叉使用。

@xiaohuoni
Copy link
Member

xiaohuoni commented Feb 18, 2019

就是这么设计的,真的要交叉使用,全部使用全局model就好了

@kennylbj
Copy link

dev可以,但是build不行,不符合设计规范呀

@xiaohuoni
Copy link
Member

就是这么设计的

@xiaohuoni
Copy link
Member

开发可以,是因为开发便捷

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

No branches or pull requests

6 participants