微信公开课
微信公开课小程序热门讨论关于「问个执行顺序方面的小白问题」的小程序开发问题
补充:问个执行顺序方面的小白问题
展开:为什么代码执行不是按顺序的啊,这就是解释语言,执行慢的晚输出啊如果想要按顺序来执行怎么弄啊预计:写入数据1循环1写入数据2循环2写入数据3循环3实际是:循环1循环2循环3写入数据11写入数据11写入数据11aaa=1 db_total=10 consolelog(1111总数1111:,db_total) while(aaa<=db_total){ thisdatamarkerspush({latitude:0,longitude:0,}), dbcollection(wy_gcb)where({t0:aaa})get({ success:res={thissetData({markers[2]longitude:resdata[0]t4}) consolelog(写入数据,aaa) },}) consolelog(循环:,aaa) aaa++; }即速小程序:Promise风格了解一下awaitdbcollection(wy_gcb)where({t0:aaa})get({success:(res)={thissetData({markers[2]longitude:resdata[0]t4})consolelog(写入数据,aaa)}}):知道了,谢谢:这是一个典型的闭包问题,用闭包思维方式来处理即可
更多有关「问个执行顺序方面的小白问题」的讨论可以前往微信公开课小程序参与互动哦!了解更多