预期为 '}' 而不是在表达式中看到 '='
Expected '}' and instead saw '=' in expression
我目前正在学习 SAP/Open UI5。我遵循了 openSAP 平台上的一些教程。现在我正在尝试自己修改一个项目(从模板 SAP Fiori 工作列表应用程序创建)。我正在 Web IDE 中编辑整个项目。
问题
要解决我遇到的问题,我的 XML 视图中有一个包含四列的 table。所有这些列都填充了来自 OData 服务的数据。
<ColumnListItem
type="Navigation"
press=".onPress">
<cells>
<ObjectIdentifier
title="{Name}"
text="{ProductID}"/>
<Text text="{SupplierName}"></Text>
<Text text="{= ${WeightMeasure} == 0 ? '-' : ${WeightMeasure}}"></Text>
<ObjectNumber
number="{
path: 'Price',
formatter: '.formatter.numberUnit'
}"
unit="{CurrencyCode}"/>
</cells>
</ColumnListItem>
上面的代码片段在 items
聚合中。当我现在启动独立应用程序时,通常会出现来自后端的记录。由于我现在已经使用 WeightMeasure 表达式 ({= ${WeightMeasure} == 0 ? '-' : ${WeightMeasure}}
) 实现了第三行,因此我在开发控制台中收到以下错误:
Uncaught (in promise) SyntaxError: Expected '}' and instead saw '=' in expression binding {= ${WeightMeasure} == 0 ? 'Hello' : ${WeightMeasure}} at position 20
at w (BindingParser-dbg.js:445)
at Function.a.complexParser [as bindingParser] (BindingParser-dbg.js:482)
at p (XMLTemplateProcessor-dbg.js:47)
at K (XMLTemplateProcessor-dbg.js:732)
at J (XMLTemplateProcessor-dbg.js:630)
at I (XMLTemplateProcessor-dbg.js:566)
at l1 (XMLTemplateProcessor-dbg.js:862)
它本身的值确实存在,并且在我输入变量时也会显示出来。
我试过的
当然,我首先检查了文档和互联网。我又找到了article for expression binding。但是当我将示例与我的版本进行比较时,它看起来确实是一样的。除非我的版本不行。
另外,我也试过几个相对路径,但最后都没有结果。看起来真的是某个地方有语法错误或者可能是什么问题?
我最近也遇到了这个问题。尝试将 ==
替换为 ===
:
text="{= ${WeightMeasure} === 0 ? '-' : ${WeightMeasure}}"
或简化
text="{= ${WeightMeasure} || '-'}"
问题是 UI5 在 Expression Binding[ 中仅支持 严格相等运算符 (===
或 !==
).
我目前正在学习 SAP/Open UI5。我遵循了 openSAP 平台上的一些教程。现在我正在尝试自己修改一个项目(从模板 SAP Fiori 工作列表应用程序创建)。我正在 Web IDE 中编辑整个项目。
问题
要解决我遇到的问题,我的 XML 视图中有一个包含四列的 table。所有这些列都填充了来自 OData 服务的数据。
<ColumnListItem
type="Navigation"
press=".onPress">
<cells>
<ObjectIdentifier
title="{Name}"
text="{ProductID}"/>
<Text text="{SupplierName}"></Text>
<Text text="{= ${WeightMeasure} == 0 ? '-' : ${WeightMeasure}}"></Text>
<ObjectNumber
number="{
path: 'Price',
formatter: '.formatter.numberUnit'
}"
unit="{CurrencyCode}"/>
</cells>
</ColumnListItem>
上面的代码片段在 items
聚合中。当我现在启动独立应用程序时,通常会出现来自后端的记录。由于我现在已经使用 WeightMeasure 表达式 ({= ${WeightMeasure} == 0 ? '-' : ${WeightMeasure}}
) 实现了第三行,因此我在开发控制台中收到以下错误:
Uncaught (in promise) SyntaxError: Expected '}' and instead saw '=' in expression binding {= ${WeightMeasure} == 0 ? 'Hello' : ${WeightMeasure}} at position 20
at w (BindingParser-dbg.js:445)
at Function.a.complexParser [as bindingParser] (BindingParser-dbg.js:482)
at p (XMLTemplateProcessor-dbg.js:47)
at K (XMLTemplateProcessor-dbg.js:732)
at J (XMLTemplateProcessor-dbg.js:630)
at I (XMLTemplateProcessor-dbg.js:566)
at l1 (XMLTemplateProcessor-dbg.js:862)
它本身的值确实存在,并且在我输入变量时也会显示出来。
我试过的
当然,我首先检查了文档和互联网。我又找到了article for expression binding。但是当我将示例与我的版本进行比较时,它看起来确实是一样的。除非我的版本不行。
另外,我也试过几个相对路径,但最后都没有结果。看起来真的是某个地方有语法错误或者可能是什么问题?
我最近也遇到了这个问题。尝试将 ==
替换为 ===
:
text="{= ${WeightMeasure} === 0 ? '-' : ${WeightMeasure}}"
或简化
text="{= ${WeightMeasure} || '-'}"
问题是 UI5 在 Expression Binding[ 中仅支持 严格相等运算符 (===
或 !==
).