[英]How do I access this function from within another scope?
I am trying to develop a sdk for a client and the client should setar its data before loading the file with javascrip. 我正在尝试为客户端开发一个sdk,并且客户端应先设置其数据,然后再使用javascrip加载文件。 The function is in global scope and my script is in another scope.
该函数在全局范围内,而我的脚本在另一个范围内。 How do I access customer data from another scope?
如何从另一个范围访问客户数据?
Global function 全局功能
window.codeInit = function () { var init = { ID: "1234", elementStart: "#contentDiv" } };
Scope of where I want to access the function data 我要访问功能数据的范围
(function(window){ //Access from here })(window)
Like this 像这样
var init = {
ID: "1234",
elementStart: "#contentDiv"
}
window.codeInit = function() {
console.log(init.ID);
};
(function(window){
codeInit();
})(window)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.