获取“未接收参考:未定义形式”。错误
我得到的是“未定义的参考文献:形式未定义”。
However, the "form is defined in an object. I am not going to post the entire JS code just where the form is declared.
line 6- const elements =
line 7- {
line 8- form: document.querySelector("#new-task-form"),
line 9- input: document.querySelector("#new-task-input"),
line 10- list: document.querySelector("#tasks"),
line 11- cal:document.querySelector("#calendar")
line 12- }
line 91- const submitHandler = (event) =>{
line 92- event.preventDefault();
line 93- createTask();
line 94- }
line 96 - form.addEventListener("submit", submitHandler);
The form.addEventListener("submit", submitHandler);
is calling back subsithandler
的功能。
I am getting the "Uncaught ReferenceError: form is not defined".
However, the "form is defined in an object. I am not going to post the entire JS code just where the form is declared.
line 6- const elements =
line 7- {
line 8- form: document.querySelector("#new-task-form"),
line 9- input: document.querySelector("#new-task-input"),
line 10- list: document.querySelector("#tasks"),
line 11- cal:document.querySelector("#calendar")
line 12- }
line 91- const submitHandler = (event) =>{
line 92- event.preventDefault();
line 93- createTask();
line 94- }
line 96 - form.addEventListener("submit", submitHandler);
The form.addEventListener("submit", submitHandler);
is calling back the function of submitHandler
. So not sure why it is giving me the error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想通了这个问题。
问题是
const task = elements.input.value
定义不正确,我将其定义为const task = input.value
I figured out the issue.
The issue was that
const task = elements.input.value
, was defined incorrectly, i had it asconst task = input.value