localStorage使用总结,页面跳转,保存值

例子

<ul id="edit" contenteditable="true">
<li>修改我吧,然后刷新页面看看,^_^</li>
</ul>
JS代码:
var edit = document.getElementById("edit");
edit.onblur = function(){
localStorage.setItem("tododata", this.innerHTML);
};
if(localStorage.getItem("tododata")){
edit.innerHTML = localStorage.getItem("tododata");
}

var TOKEN_KEY = "jwtToken";

//取值

function getJwtToken() {
        return localStorage.getItem(TOKEN_KEY);
    }

//保存
    function setJwtToken(token) {
        localStorage.setItem(TOKEN_KEY, token);
    }

//删除
    function removeJwtToken() {
        localStorage.removeItem(TOKEN_KEY);
    }

参考下:https://www.cnblogs.com/st-leslie/p/5617130.html

上一篇:Nginx 教程(2):性能


下一篇:ArcGIS Server 10.2 实战(三)图层标注及图例中文显示乱码的解决