我是App Inventor的初学者,我不知道自己在function return1() {
return Promise.resolve(1);
}
function wait(ms) {
return new Promise(function (resolve) {
setTimeout(resolve, ms);
});
}
function increment(val) {
return wait(1000).then(function () {
return val + 1;
});
}
function square(val) {
return wait(1000).then(function () {
return val * val;
});
}
var p = return1()
.then(increment)
.then(square); // Returns a promise that will resolve to 4 (eventually)
p.then(function (result) { console.log(result); });
做错了什么。
我正在尝试创建和应用以重现我存储在服务器中的音乐但是当我显示listpicker
时,我无法点击任何选项,而且我无法返回到第一个屏幕。在这里,我把我的代码:
图片1 图2
我尝试删除显示listpicker
的行,但它只显示为全黑屏幕。
我刚刚发布的代码的结果正是我所看到的列表,其中包含我已经上传到服务器的2首歌曲的名称和链接,但是当我点击它们时它没有做任何事情。
感谢您的帮助。
答案 0 :(得分:1)
Web
组件异步工作,这意味着需要一点点,直到结果可用。您将在Web.GotText
事件中获得结果。
因此,在updateListpicker
事件中调用Listpicker.BeforePicking
过程没有意义,因为结果仍然不可用,并且您会显示一个空的listpicker。在收到结果之前,将打开listpicker!
将listpicker设置为visible = false,并使用button.click事件调用updateListpicker
过程。然后,您已在Web.GotText
事件中执行此操作,请分配收到的列表到listpicker并打开它。