syntax-error - 为什么 WebIDE 显示 Select 元素的错误?

标签 syntax-error sapui5 web-ide

我在 WebIDE 中的 SAPUI5 中编写了一个应用程序。当我将选择项目添加到页面时,它显示并出现错误,但程序可以正常运行,WebIDE 中出现错误的原因是什么?
部分代码:

<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic" xmlns:footerbar="sap.ushell.ui.footerbar" controllerName="xxx.controller.Worklist">
    <semantic:FullscreenPage id="page" navButtonPress="onNavBack" showNavButton="true" title="{i18n>worklistViewTitle}">
        <semantic:content>
            .....
        </semantic:content>
        <semantic:customFooterContent>
      // Here it shows error: Semantic Error: SAPUI5: The Association property is incorrect. Please enter the correct value. 
            <ActionSelect xmlns:sap.ui.core="sap.ui.core" selectedItem="Element sap.ui.core.ListItem#__item1" selectedKey="item1" selectedItemId="__item1" id="__select_lang">
                <items>
                    <sap.ui.core:ListItem text="English" key="EN" id="__item1"/>
                    <sap.ui.core:ListItem text="German" key="DE" id="__item2"/>
                </items>
            </ActionSelect>
        </semantic:customFooterContent>
    </semantic:FullscreenPage>
</mvc:View>
错误信息是:
错误:语义错误:SAPUI5:关联属性不正确。请输入正确的值。
我在显示它的代码中进行了标记。

最佳答案

这是selectedItem关联:它确实包含一个无效值(在运行时被忽略)。

关联是通过 XMLViews 中元素的 id 设置的。

您正在使用三种方式一次预选一个项目。请只选择一个。

  • selectedItem是一个关联,必须设置为所选项目的 id。这种聚合很少使用。
  • selectedKey必须设置为应选择的项目的键(在您的情况下为 EN 或 DE)。
  • selectedItemId必须设置为应选择的项目的 id。此属性通常优先于 selectedItem 关联。

  • 在您的示例中,它应该是这样的:

    <ActionSelect xmlns:sap.ui.core="sap.ui.core" selectedItemId="__item1" id="__select_lang">
    

    关于syntax-error - 为什么 WebIDE 显示 Select 元素的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40305233/

    相关文章:

    vb.net - “文本”不明确-错误(vb.net)

    javascript - SAP UI5::拖放链接

    javascript - 项目导入 Chrome+Codio 时未加载库

    docker - Gitlab CE引发错误,Web IDE卡在nginx反向pxy(jwilder)后面

    syntax-error - reshape 长多个变量时出错

    python - 避免 python 中 'as' 语句的语法错误

    node.js - app.delete 在使用 nodeclipse IDE 的 Express 上引发语法错误

    javascript - 更改组合框中第一个滚动中可见的元素数

    data-binding - 从表到对话框的数据绑定(bind) + 将数据从对话框更新到表 SAPUI5