[英]How can i access the functions from other JS files
(function () {
pm.view.functionName= function () {
function nameFunction() {
var something;
return something;
}
return win;
};
})();
I am in another JS file and i want to call this nameFunction()... how can i do this. 我在另一个JS文件中,我想调用此nameFunction()...如何执行此操作。 I tried... 我试过了...
pm.view.functionName().nameFunction()
But i get an error called, cannot call function in the Object. 但是我得到一个错误,不能在对象中调用函数。 How can i access the functions from other JS files. 如何从其他JS文件访问功能。
The function nameFunction
exists in the scope of the function functionName
. 函数nameFunction
存在于函数functionName
的范围内。 You cannot access it from outside that function. 您不能从该功能外部访问它。
If you want to do so, you'll have to explicitly say so: 如果要这样做,则必须明确地这样说:
pm.view.functionName.nameFunction = function() {
var something;
return something;
};
You could then access it as pm.view.functionName.nameFunction()
. 然后,您可以通过pm.view.functionName.nameFunction()
进行访问。
nameFunction
is local to pm.view.functionName
and you cannot access it, just like you cannot access local variables. nameFunction
是本地的pm.view.functionName
,你不能访问它,就像你不能访问局部变量。 You can call nameFunction()
only when being inside pm.view.functionName
. 您只能在pm.view.functionName
内时调用nameFunction()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.