InvalidValueError: not an instance of HTMLInputElement

前端 未结 8 1663
刺人心
刺人心 2020-12-09 08:23

FYI, I\'m not a JavaScript Ninja but felt like I\'ll become one when I did a lot of things based on Google Maps recently.

I implemented a map. User can search for go

8条回答
  •  一个人的身影
    2020-12-09 08:55

    Had the same issue while following the Google Tutorial. In my case the problem turned out to be the async keyword, which was causing the Google Maps script to execute asynchronously while the rest of the page continued parsing. Here's the fix:

    1. Put the Google Maps script after the relevant HTML element (as pointed out by Prashant)
    2. Call the Google Maps script using the defer keyword and not the async keyword. Code:
    
    

    Using defer makes sure the script is executed when the page has finished parsing (source).

提交回复
热议问题