Autojs development: When calling other js file functions, the function defined in the file cannot be referenced through "." (solved)

Table of contents

Non-full path reference

full path reference

Summarize


Non-full path reference

Generally, novice developers refer to it like this

var myUtils = require('MyUtils.js');
var myDialog = require('DialogUtils.js');

The called js file can be referenced normally, but it greatly affects development because you can't type 3 by hand if you can't get "." out!

At the same time, you cannot use ctrl+left mouse button to jump to the past.

But it doesn't work if you want to jump to the location of the defined function. For example: isEmpty() function.

isEmpty function in myUtils.js file.

/** 字符串是否为空 */
myUtils.isEmpty = function(txt){
    if(txt==""||txt==null||txt==undefined){
       return true;
    }else{
        return false;
    }
}

full path reference

var myUtils = require('D:/Auto.js/demo/demo_xuexi/.vscode/MyUtils.js');
var myDialog = require('D:/Auto.js/demo/demo_xuexi/.vscode/DialogUtils.js');

You can get all the reference locations of the functions in the myUtils file, and "." out the relevant function references to facilitate development and maintenance.​ 

 

 

Summarize

The full path must be used when referencing, so that you can use related functions and variables of other js files at any time

Guess you like

Origin blog.csdn.net/piyangbo/article/details/126223597