我有一个包含一些磁贴的XMLView主页.这些切片是从JSON文件填充的.磁贴具有'title'属性,需要i18n数据绑定.
XML视图的一部分:
<TileContainer id="container" tiles="{/TileCollection}">
<StandardTile
icon="{icon}"
title="{title}"
press="onPress" />
</TileContainer>
Run Code Online (Sandbox Code Playgroud)
JSON文件:
{
"TileCollection" : [
{
"icon" : "sap-icon://document-text",
"title" : "{i18n>foo}"
},
... etc
Run Code Online (Sandbox Code Playgroud)
我完成数据绑定的旧方法直接在视图中title="{i18n>foo}".当然,现在我基本上有两层数据绑定,一个用于i18n的JSON,另一个用于获取JSON(获取i18n)的视图.
这也是我设置i18n模型的Component.js.
sap.ui.core.UIComponent.extend("MYAPP.Component", {
metadata: {
rootView : "MYAPP.view.Home", //points to the default view
config: {
resourceBundle: "i18n/messageBundle.properties"
},
... etc
init: function(){
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
var mConfig = this.getMetadata().getConfig();
var oRouter = this.getRouter();
this.RouteHandler = new sap.m.routing.RouteMatchedHandler(oRouter);
oRouter.register("router");
oRouter.initialize();
var sRootPath = jQuery.sap.getModulePath("MYAPP");
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl : [sRootPath, mConfig.resourceBundle].join("/") …Run Code Online (Sandbox Code Playgroud) 我想在本地存储中添加60件东西.在for循环中,我正在创建一个对象,将其转换为字符串并将其添加到localstorage,并将时间作为键.
function populate()
{
for(var i=0; i < 60; i++)
{
var newDate = new Date();
var card = {
'name': i,
'cost': i,
'type': i,
'text': i,
'power': i,
'toughness': i};
localStorage.setItem(newDate.getTime(), JSON.stringify(card));
}
}
Run Code Online (Sandbox Code Playgroud)
逻辑规定这应该发生60次.在实践中,它发生在大约2到20次之间,并且给予对象属性的i的值变化很大.有时我得到2的值为11和59,有时我得到18,数字从1到59或60.这个for循环不会迭代多少次,但它甚至没有按顺序执行,它似乎是随机的.
这里发生了什么?