如何使用聚合物1.0中的缓存功能来保存和重用元素数组
How to use cache feature in polymer 1.0 to save and reuse an array of elements?
我们拥有白金元素platinum-sw-cache,可以离线管理数据。
基本上,我正在尝试创建一个元素,显示最近使用的项目列表在我的应用程序,我认为缓存是实现它的方法。
如何使用元素保存数组,以便以后使用
你能试试吗?
<dom-module id="recent-items">
<template>
<iron-localstorage name="my-app-storage"
value="{{recentFood}}"
on-iron-localstorage-load-empty="initializeDefault"
></iron-localstorage>
<template is ="dom-repeat" items={{recentFood}}>
<div class="horizontal layout">{{item}}</div>
</template>
</template>
<script>
Polymer({
is: 'recent-items',
properties: {
recentFood: {
type: Array
}
},
// initializes default if nothing has been stored
initializeDefault: function() {
var tempItems=new Array();
tempItems[0]="Pizza";
this.recentFood=tempItems.slice();
},
// use path set api to propagate changes to localstorage
makeModifications: function() {
}
});
</script>
</dom-module>
相关文章:
- 保存数组javascript
- 保存表中的行's在数组中的tbody,稍后使用它们
- 保存id数组's而不是对象
- JavaScript-保存、存储和更新数组
- Javascript-将类型化数组保存为blob,并作为二进制数据读回
- 使用javascript/jquery从现有数组中创建一个新数组,该数组保存项目存在的次数
- AJAX将JSON数组保存到多个JS变量中
- 我的函数不会返回要保存在数组中的对象
- Javascript数组只保存最近的对象
- 将对象属性保存到数组时出现奇怪的重复
- 将地理编码器的位置保存到数组中
- 如何在排序前保存数组的副本
- 如何使用保存数组名称的变量将对象文本添加到数组
- 使用猫鼬保存数组数据的更干净的代码
- Javascript:保存数组中重复项的索引
- 在重新加载时保存数组值并将其取回
- 如何在parse.com+AngularJS中使用for循环保存数组中的每个对象
- 使用postgresql保存数组进行Sequelize
- 对象,用于保存数组JQuery
- 如何在文件上快速保存数组