【问题标题】:Why does the WebIDE shows an error for Select elements?为什么 WebIDE 显示 Select 元素的错误?
【发布时间】:2017-03-11 08:31:36
【问题描述】:

我在 WebIDE 中用 SAPUI5 编写了一个应用程序。当我将 Select items 添加到页面时,它显示并出错,但程序可以正常运行 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:关联属性不正确。请输入正确的值。

我在显示的代码中标记了它。

【问题讨论】:

    标签: syntax-error sapui5 web-ide


    【解决方案1】:

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

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

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

    • selectedItem 是一个关联,必须设置为所选项目的 id。这种聚合很少使用。

    • selectedKey 必须设置为应选择的项目的键(ENDE 在您的情况下)。

    • selectedItemId 必须设置为应选择的项目的 ID。此属性通常优先于 selectedItem 关联。

    在你的例子中应该是这样的:

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

    【讨论】:

    • 非常感谢您的解释。事实上,我并没有自己编写这段代码。此代码已由 SAP Web IDE 生成。因此,如果只需要分配其中一项,那么就是 Web IDE 中的一个错误导致了所有 3 项。
    猜你喜欢
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 2023-02-03
    • 2016-09-06
    • 2022-06-13
    • 2019-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多