相关疑难解决方法(0)

当 JavaScript 加载时,本地存储不会在我的 chrome 上刷新,除非我刷新

当我在 formButton 监听器中调用collectform回调函数时,一切都很好,除了我没有立即看到chrome本地存储中的对象数据,除非我手动刷新本地存储。

 function collectFormData(e) {
        e.preventDefault()
        let noteTitle = tiTxt.value
        let noteContent = pTxt.value
        let date = new Date()
        const currTime = (date.toLocaleString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }));
       
        let noteObj = {
            noteTitle,
            noteContent,
            loc,
            currTime
        }
        if (!noteTitle && !noteContent === true) {
            alert('Add note title and content');
        } else {
            allNotes.push(noteObj)
            wlocalStorage.setItem('noteData', JSON.stringify(allNotes));
            (function () {
                return JSON.parse(localStorage.getItem('noteData'));
            })() 
            let payload = noteObj;
            payloadArray.push(payload)
            // xhr object listen on the server and send data …
Run Code Online (Sandbox Code Playgroud)

javascript local-storage node.js

6
推荐指数
0
解决办法
830
查看次数

标签 统计

javascript ×1

local-storage ×1

node.js ×1