我试图通过检查具有类似错误的其他问题来找到解决方案,但没有一个可以帮助我。我试图在沙箱中从我的应用程序运行Component.js。运行index.html工作正常。我的起始观点是这样的:
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
controllerName="com.sap.build.standard.qrCodeScanner.controller.Home"
>
<Page id="home"
class="customHomeBackground"
showHeader="true"
title="Home"
showFooter="true"
>
<content>
<FlexBox
class="customFlexBoxHome"
justifyContent="Center"
alignItems="Center"
wrap="Wrap"
>
<GenericTile class="customTile"
header="Scan invitations"
subheader="from your customers"
frameType="OneByOne"
press="_onGenericTilePress1"
>
<TileContent>
<ImageContent src="sap-icon://bar-code"/>
</TileContent>
</GenericTile>
</FlexBox>
</content>
<footer/>
<headerContent/>
<subHeader/>
<customHeader/>
</Page>
</mvc:View>
Run Code Online (Sandbox Code Playgroud)
它只是一个单一的GenericTile
. 我无法访问此视图,因为
错误:如果没有为控件 sap.m.GenericTile 定义默认聚合,则无法添加直接子项
访问其他视图没有问题。因此,当我添加例如按钮而不是GernericTile
+ 子项时,它工作正常。
我还尝试添加这些示例图块之一,但是同样的错误。有什么问题GenericTile
?
我目前对JavaScript操作的性能有疑问。
我想为ID已在数组中aInvited
或不在数组中的对象清理对象数组(aEmployees)aInvitationAllowed
:
var iLength = aEmployees.length - 1;
for (var i = iLength; i >= 0; --i) {
if (aInvited.indexOf(aEmployees[i].id) !== -1 || aInvitationAllowed.indexOf(aEmployees[i].id) === -1) {
aEmployees.splice(i, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
您可以想象我有Employee对象(aEmployees)。我还具有已被邀请参加事件的员工ID列表(aInvited)和已被邀请参加事件的员工ID列表(aInvitationAllowed)。因此,我希望所有员工都能邀请我参加该活动。
问题是indexOf
查询行。我必须假设数组有很多条目(〜100,000个条目)。然后可能是循环需要一段时间。
因此,我对您的问题是:如何使循环更快?有更快的替代方法indexOf
吗?
感谢您的提示!