openui5 在 xml 视图中找不到 <template:repeat>

openui5 can't find <template:repeat> in xml view

根据:sap documentation: repeat 我应该可以使用重复标记来遍历我的数据。 我添加了模板命名空间 xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1" 但是当我尝试 运行 我的代码时它给出了以下错误:

Uncaught Error: failed to load 'http://schemas/sap/com/openui5/extension/sap/ui/core/template/1/repeat.js' from webjars/openui5/1.42.6/

我无法更改我的 openui5 版本。 我在 Eclipse 中使用 openui5 前端和 Java 服务后端。

这个错误看起来像 UI5 正在尝试加载预处理器指令,就好像它们是控件一样。因为在预处理过程中还没有加载控件,所以我猜这是在视图控件树实例化期间发生的。这反过来表明,在构建控件树时,模板指令仍然存在于 XML 视图中。

您确定在实例化视图之前确实进行了 "activated" XML 预处理吗?查看 XML 预处理 documentation(更具体地说,"calling the preprocessor" 示例)。

实际上,现在我再次阅读你的问题,我想你想使用 XML 预处理指令来构建 UI 基于你的数据。情况并非如此,您应该仅使用 XML 预处理/模板来构建视图 基于您的元数据 (即只有一次,第一次显示视图)。

要根据您的数据调整视图,您应该使用 data binding instead. More specifically, you should use aggregation binding 来模拟循环。