帖子
帖子
用户
博客
课程
显示全部楼层
7
帖子
0
勋章
57
Y币

[云开发] scrollPicture使用云数据库中url时,出现闪退情侣

[复制链接]
发表于 2015-5-13 15:32:57
  1.                         var arrayPath = new Array();
  2.                         var arrayTitle = new Array();
  3. //                        arrayPath[0] = 'http://aa5727d3031dd7d42978.b0**.**/apicloud/c883b40eea3189de1101d94fb2c2933c.jpg';
  4. //                        arrayPath[1] = 'http://aa5727d3031dd7d42978.b0**.**/apicloud/e3754335ff0bb91363c6e4670df1bdcf.jpg';
  5. //                        arrayPath[2] = 'http://f.hiphotos**.**/image/pic/item/4e4a20a4462309f7bdca9423710e0cf3d7cad65d.jpg';
  6. //                        arrayPath[3] = 'http://aa5727d3031dd7d42978.b0**.**/apicloud/c883b40eea3189de1101d94fb2c2933c.jpg';
  7. //                        arrayPath[4] = 'http://aa5727d3031dd7d42978.b0**.**/apicloud/c883b40eea3189de1101d94fb2c2933c.jpg';
  8. //                       
  9.                         var model = api.require('model');
  10.                         var query = api.require('query');
  11.                         model.config({
  12.                                 appKey : 'BA84BDC4-AE99-74F6-31B7-17B2568AFA5F',
  13.                                 host : 'https://d.apicloud.com'
  14.                         });
  15.                         query.createQuery(function(ret, err) {
  16.                                 if (ret && ret.qid) {
  17.                                         var queryId = ret.qid;
  18.                                         model.findAll({
  19.                                                 class : 'advertisement',
  20.                                                 qid : queryId
  21.                                         }, function(ret, err) {
  22.                                                 if (ret) {
  23.                                                 for(i = 0; i < ret.length; i++){
  24.                                                         arrayPath[i] = ret[i].img.toString();
  25.                                                         alert(arrayPath[i]);
  26.                                                         }
  27.                                                 } else {
  28.                                                         api.toast({
  29.                                                                 msg : err.msg,
  30.                                                                 location : 'middle'
  31.                                                         })
  32.                                                 }
  33.                                         });
  34.                                 }
  35.                         });
  36.                         arrayTitle[0] = '第一张';
  37.                         arrayTitle[1] = '第二张';
  38.                         arrayTitle[2] = '第三张';
  39.                         arrayTitle[3] = '第四张';
  40.                         arrayTitle[4] = '第五张';
  41.                         var obj = api.require('scrollPicture');
  42.                         obj.open({
  43.                                 x : 0,
  44.                                 y : 0,
  45.                                 h : 200,
  46.                                 fixedOn : api.frameName,
  47.                                 fixed : false,
  48.                                 placeholderImg : 'widget://res/scrollPicture_placehloder.png',
  49.                                 paths : arrayPath,
  50.                                 subtitle : {
  51.                                         titles : arrayTitle
  52.                                 },
  53.                                 control : {
  54.                                         position : 2
  55.                                 }
  56.                         }, function(ret, err) {
  57.                                 if (ret.status) {
  58.                                         ret.click
  59.                                 } else {
  60.                                         ret.index
  61.                                 }
  62.                         });
  63. 单独将url值赋值给数组时是可以使用的,但是从云数据库取url下来是就不行,我用alert来显示一下,确实可以得到url,可是一用就崩溃,,,,
复制代码

0
帖子
0
勋章
1058
Y币
闪退是因为arrayPath为空,你应该在获取完arrayPath再执行scrollPicture,也就是在createQuery的CallBack执行
7
帖子
0
勋章
57
Y币
好的谢谢,
您需要登录后才可以回帖 登录

本版积分规则