Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
得到错误:
'localStorage' was used before it was defined.
我需要做什么来解决这个问题?
localStorage在所有现代浏览器上都可用,据我所知不需要定义。
localStorage
任何您希望显示为 jslint 定义的全局变量都可以在全局变量的注释中定义。例如:
/*global localStorage: false, console: false, $: false */
这将使 localStorage、console 和 $ (jQuery) 不会触发该警告。
它不知道如何使用代码。您需要设置浏览器选项。请注意,这是 jshint.com 中的默认值,但不是 jslint.com