vueComponent / pro-components

easy use `Ant Design Vue` layout
MIT License
535 stars 214 forks source link

3.1.x 之后的版本 运行报错 TypeError: Cannot read properties of undefined (reading 'prefixCls') #152

Closed NavOrange closed 3 years ago

NavOrange commented 3 years ago

重现步骤:

  1. yarn create vite (vue3 + ts)
  2. yarn add vue-router@next less @ant-design-vue/pro-layout@next
  3. copy example/ to src/
  4. yarn dev

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'prefixCls') at setup47 (MenuItem.js:49) at callWithErrorHandling (runtime-core.esm-bundler.js:6992) at setupStatefulComponent (runtime-core.esm-bundler.js:6608) at setupComponent (runtime-core.esm-bundler.js:6564) at mountComponent (runtime-core.esm-bundler.js:4423) at processComponent (runtime-core.esm-bundler.js:4398) at patch (runtime-core.esm-bundler.js:3993) at mountChildren (runtime-core.esm-bundler.js:4189) at processFragment (runtime-core.esm-bundler.js:4357) at patch (runtime-core.esm-bundler.js:3986)

像是 pro-layout 使用 menuItemRender 导致的

jianshen-weo commented 3 years ago

我也是这个问题,之前反馈过了,很奇怪的是examples运行不会报这个错,对比了很多地方,至今都没解决,希望up关注一下这个问题!

sendya commented 3 years ago

本人测试过没有问题,尝试清空 node_modules 后重装依赖再试试?

如果你遇到此类问题。请考虑提供一个可复现的代码仓库 否则光凭这么一段内容 无法查到是为什么

sendya commented 3 years ago

这是 prolayout 的 template,如果不会搭配环境可以直接考虑使用本 template 代码; https://github.com/sendya/preview-pro

NavOrange commented 3 years ago

感谢回复 补上仓库 https://github.com/Shuhua95/preview-pro

jianshen-weo commented 3 years ago

这是 prolayout 的 template,如果不会搭配环境可以直接考虑使用本 template 代码; https://github.com/sendya/preview-pro up,您好,我将代码fork了一份出来,然后加上了菜单自定义渲染,您看下这个问题! 仓库地址:https://github.com/jianshen-weo/antdv-layouts

sendya commented 3 years ago

image

跟 provide, inject 有关,暂时无解

sendya commented 3 years ago

手动包装的 menu-item 没有包装在 menu 下,所以无法享用 menu 的 provide inject

jianshen-weo commented 3 years ago

手动包装的 menu-item 没有包装在 menu 下,所以无法享用 menu 的 provide inject

感谢耐心回复啦!有什么替代方案可是实现自定义菜单吗?

sendya commented 3 years ago

@jianshen-weo @Shuhua95 升级到 3.1.0-beta.6 应该可以解决

sendya commented 3 years ago

image

NavOrange commented 3 years ago

为什么改下了 menu 的导入就可以工作了 🤔