javascript - why VScode sometimes don't find the reference? -
it doesn't happen time, visual studio code cannot find variable in other file, , don't know why.
for example, have 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();
in monitor.js:
notificationmanager.attentionrequest();//vscode don't find
you trying access variable/function declared in js file not available @ time of access. hence, need change order of js files
update from
<script src="monitor.js"></script> <script src="notificationmanager.js"></script>
to
<script src="notificationmanager.js"></script> <script src="monitor.js"></script>
Comments
Post a Comment