📜  控制台表单元素作为 json 对象 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:52.094000             🧑  作者: Mango

代码示例1
function handleSubmit(event) {
    event.preventDefault();

    const data = new FormData(event.target);

+   const value = Object.fromEntries(data.entries());

    console.log({ value });
  }

  const form = document.querySelector('form');
  form.addEventListener('submit', handleSubmit);