它不会一直发生,但是有时Visual Studio Code找不到其他文件中的变量,我也不知道为什么。
例如,我有一个index.html
<script src="monitor.js"></script>
<script src="notificationManager.js"></script>
notificationManager.js
var NotificationManager = function() {
this.attentionRequest = function() {
console.log("Attention");
};
}
var notificationManager = new NotificationManager();
在我的monitor.js中:
notificationManager.attentionRequest();//VSCode don't find this
您正在尝试访问在访问时不可用的js文件中声明的变量/函数。因此,您需要更改JS文件的顺序
从更新
<script src="monitor.js"></script>
<script src="notificationManager.js"></script>
到
<script src="notificationManager.js"></script>
<script src="monitor.js"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句