如何将onload函数的返回值推送到全局变量
var myids = '';
function passid(){
onload = function () {
uidt = tempid.ssid; // some value getting from API
}
}
passid();
console.log(myids);
任何人都可以帮我解决这个问题,如何将 uitd 推送到 var myids 以便我可以在任何我想要的地方使用。
var myids = '';
function passid(){
onload = function () {
uidt = tempid.ssid; // some value getting from API
}
}
passid();
console.log(myids);
Can Anyone help me with this, How to push uitd to var myids so I can be use wherever I want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 API 请求肯定是异步的,因此您可以使用 promises 如果您位于异步函数内部,则通过 async wait ;如果您位于异步函数外部,则通过 then 和 catche
Your API request is definitely asynchronous, so you can use the promises via async await if you are inside an asynchronous function or then and catche if you are outside an asynchronous function