繁体   English   中英

本地存储问题 - index.html: Uncaught TypeError: Cannot read properties of null (reading 'value')

[英]Problem with local storage - index.html: Uncaught TypeError: Cannot read properties of null (reading 'value')

这是错误的另一部分 - 在 HTMLButtonElement.onclick (index.html:4) 处的 saveData (index.html:492:119)

我用来输入页面中的每个字段

但不幸的是我得到这个错误到底是什么问题,因为在本地存储中已经生成了密钥,但是在按下保存后我得到一个错误并且没有存储任何内容

我带的输入框的ss

在此处附加代码段 -

https://github.com/akshat-growthx/newnew/blob/main/index.html

我修复了您的 HTML 并进行了有效保存

https://jsfiddle.net/mplungjan/ks0zrp47/

document.getElementById("save").addEventListener("click",function() {
  const obj = [...document.querySelectorAll("section[id][contenteditable]")].map(sec => ({[sec.id]: sec.textContent.trim()}))
  console.log(obj)
  localStorage.setItem("content_input", JSON.stringify(obj))
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM