事件对象到底是什么?
什么是事件对象?什么时候执行?为什么我们有它? 例如:
当我们像本例一样使用匿名函数时,事件对象将不是
renderPosts()
函数。window.addEventListener('DOMContentLoaded', () => renderPosts()); const renderPosts = async () =>; { 让 uri = 'http://localhost:3000/posts?_sort=likes&_order=desc'; const res = 等待 fetch(uri); const container = document.querySelector(".blogs");```
当我们不使用匿名函数(如本例所示)时,事件对象将是
renderPosts()
函数。window.addEventListener('DOMContentLoaded',renderPosts()); const renderPosts = async () =>; { 让 uri = 'http://localhost:3000/posts?_sort=likes&_order=desc'; const res = 等待 fetch(uri); const container = document.querySelector(".blogs");```
我没有看到其中的区别,也没有真正理解它。
What is an event object? When is it executed? Why do we have it?
For example:
when we use an anonymous function as in this example, the event object will not be
renderPosts()
function.window.addEventListener('DOMContentLoaded', () => renderPosts()); const renderPosts = async () => { let uri = 'http://localhost:3000/posts?_sort=likes&_order=desc'; const res = await fetch(uri); const container = document.querySelector(".blogs");```
when we do not use anonymous function as in this example, the event object will be
renderPosts()
function.window.addEventListener('DOMContentLoaded',renderPosts()); const renderPosts = async () => { let uri = 'http://localhost:3000/posts?_sort=likes&_order=desc'; const res = await fetch(uri); const container = document.querySelector(".blogs");```
I do not see the difference and not really understand it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论