从 Vaadin 22 升级到 24 后,一些内置组件(例如组合框或网格)无法在与 Vaadin 22 一起正常运行的应用程序中显示。 我们正在使用:
Vaadin 24.1.1,具有 npn、Vite 和生产模式。
Spring Boot 3.1.1
应用程序的日志显示以下消息:
2023-07-07T10:58:56.045+02:00 ERROR 3404 --- [http-nio-9012-exec-9] c.v.flow.component.internal.UIInternals : The component class com.vaadin.flow.component.combobox.ComboBox includes '@vaadin/combo-box/src/vaadin-combo-box.js' but this file was not included when creating the production bundle. The component will not work properly. Check that you have a reference to the component and that you are not using it only through reflection. If needed add a @Uses(ComboBox.class) where it is used.
2023-07-07T12:55:41.395+02:00 ERROR 19744 --- [http-nio-9012-exec-2] c.v.flow.component.internal.UIInternals : The component class com.vaadin.flow.component.details.Details includes '@vaadin/details/src/vaadin-details.js' but this file was not included when creating the production bundle. The component will not work properly. Check that you have a reference to the component and that you are not using it only through reflection. If needed add a @Uses(Details.class) where it is used.
并且生成页面的源代码有一个空标签vaadin-combo-box:
<vaadin-combo-box></vaadin-combo-box>
我们已经多次删除了 Vaadin 生成的 node_modules 和 fronted 目录,但没有任何变化。有没有人可以帮助我们?
最佳答案
我们使用如下代码动态注册路由:
RouteConfiguration.forSessionScope().setRoute("home", HomeView.class, MainLayout.class);
哪里MainLayout.class
扩展 AppLayout
问题在于 HomeView.class
中使用的组件且未用于 MainLayout.class
不显示。
我们必须添加注释 @Uses
至MainLayout.class
与组件,例如:
@Uses(ComboBox.class)
现在所有组件都正确显示了。
其他解决方案是使用属性 <optimizeBundle>false</optimizeBundle>
在 build-frontend
pom.xml 的目标
这种行为非常奇怪,因为在 Vaadin 22 中,应用程序在没有 @Uses
的情况下工作正常。注释。
关于java - 从 v22 升级到 v24 后,某些 Vaadin 组件未呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76636685/