Skip to content

Commit

Permalink
Merge pull request #17 from im0qianqian/master
Browse files Browse the repository at this point in the history
重新组织 localStorage 存储形式 & 解决 localStorage 无法及时清理的问题
  • Loading branch information
welefen authored Apr 30, 2019
2 parents b916edb + df2a42f commit 72284ba
Show file tree
Hide file tree
Showing 2 changed files with 405 additions and 385 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ $.pjax({
callback: function(){}
})
```
**注意:若设置 storage 为 true,为避免多次请求页面后导致本地 localStorage 容量不足而触发异常,请在页面加载完成后加载以下 JavaScript 代码清除已过期的记录。**

```javascript
if (!!window.localStorage) {
for (var key in localStorage) {
try {
if ((key.split("_") || [""])[0] === "pjax") {
var item = localStorage.getItem(key);
if (item) {
item = JSON.parse(item);
if ((parseInt(item.time) + 600 * 1000) <= new Date * 1) {
localStorage.removeItem(key)
}
}
}
} catch (e) { }
}
}
```



### qwrap版

qwrap版需要在页面引入qwrap和对应的ajax组件。
Expand Down
Loading

0 comments on commit 72284ba

Please sign in to comment.