1
1
在你的
|
2
0
不要再声明gameOn变量你可以直接使用变量 游戏=。。。 ,因为它在函数的外部作用域中声明,并在内部作用域中可用 |
3
0
正如其他人所说,不要两次声明gameOn,它应该会成功的。 但是我已经阅读了越来越多关于JavaScript中全局变量的“邪恶”的内容,特别是因为全局名称空间意味着任何东西都可以编辑这些变量,甚至其他脚本。 很多人似乎倾向于将变量包装在一个对象中,比如:
然后,使用“globals.buttonColors”来引用变量。 如果你计划保持范围小,不是100%必要的,但无论如何都是一个很好的做法。 |
Softly · 单选按钮未按预期取值 1 年前 |
SlickRed · 我无法使用JS关注HTML元素 1 年前 |
assembler · Nextjs没有处理发布请求 1 年前 |
BADRUM · 执行两个获取功能后,如何导航回页面? 1 年前 |
Toniq · javascript为php保存多维数组 1 年前 |