收藏
回答

帮忙看看,为什么实现不了多张图片

//.js

Page({


  /**

   * 页面的初始数据

   */

  data: {

    currentTab: 0,

    

    imgalist0: [ 'https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/309586315285779976.jpg',

      'https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/e6b5f06c7655fd7fa9699987c4578641_u%3D1837457002%2C1490875854%26fm%3D27%26gp%3D0.jpg' 

              ],

    imgalist1: ['https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/e6b5f06c7655fd7fa9699987c4578641_u%3D1837457002%2C1490875854%26fm%3D27%26gp%3D0.jpg',

      'https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/309586315285779976.jpg' 

    ],

    imgalist2: ['https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/309586315285779976.jpg',

'https://lg-1c7jwm16-1257218715.cos.ap-shanghai.myqcloud.com/309586315285779976.jpg'

    ]

  

  },

   /** 

     * 预览图片

     */

  previewImage: function (e) {

    var current = e.target.dataset.src;

    wx.previewImage({

      current: current, // 当前显示图片的http链接

      urls: this.data.imgalist0,

      urls: this.data.imgalist1,

      urls: this.data.imgalist2,// 需要预览的图片http链接列表

    })

  }

  })

  

  

  

  

  

  

<!--pages/index/index/tb/tb.wxml-->

<view class="swiper-tab">

    <view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">第一个</view>

    <view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">第二个</view>

    <view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab">第三个</view>

</view>


<view>

<swiper current="{{currentTab}}" duration="300"  bindchange="swiperTab">

<swiper-item>

<view wx:for="{{imgalist0}}"  wx:key="key" wx:for-item="image" class="previewimg">

<image src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image>

</view>

</swiper-item>

<swiper-item>

<view wx:for="{{imgalist1}}"  wx:key="key" wx:for-item="image" class="previewimg">

<image src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image>

</view>

</swiper-item>

<swiper-item>

<view wx:for="{{imgalist2}}"  wx:key="key" wx:for-item="image" class="previewimg">

<image src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image>

</view>

</swiper-item>


</swiper>

</view>


商品可以实现分类啦,在每个分类下放两张图片以上,却只能显示一张图片的内容,这是为什么,编辑器也没有显示代码有出现错误,但是就是显示不了,我想要的效果,求大家帮忙看看,这是为什么?


回答关注问题邀请回答
收藏

2 个回答

  • 2018-08-23

    把三个数组合并在一起 然后再赋值urls

    2018-08-23
    有用 1
    回复
  • 卢霄霄
    卢霄霄
    2018-08-22

    urls:["图一", "图二", "图三"]

    2018-08-22
    有用 1
    回复 11
    • 去听風啊
      去听風啊
      2018-08-22

      好像这样不行,因为里面的data里的  imgalist0,  imgalist1,  imgalist2,的值传递给谁呀!

      2018-08-22
      回复
    • 卢霄霄
      卢霄霄
      2018-08-22回复去听風啊

      let list = this.data.imagelist0.concat(this.data.imagelist1, this.data.imagelist2)

      urls : list

      2018-08-22
      回复
    • 去听風啊
      去听風啊
      2018-08-22回复卢霄霄

      实现不了,编译器说是无名错误,为什么?

      2018-08-22
      回复
    • 卢霄霄
      卢霄霄
      2018-08-22回复去听風啊

      截图看看你写的呢,另外也截图看看报错呢

      2018-08-22
      回复
    • 去听風啊
      去听風啊
      2018-08-22回复卢霄霄

      /**

          * 预览图片

          */

      previewImage: function (e) {

      var current = e.target.dataset.src;

      let list = this.data.imagelist0.concat(this.data.imagelist1, this.data.imagelist2)

      urls: list;

      let list = this.data.imagelist1.concat(this.data.imagelist0, this.data.imagelist2)

      urls: list;

      let list = this.data.imagelist2.concat(this.data.imagelist1, this.data.imagelist0)

      urls: list  ;

      wx.previewImage({

      current: current, // 当前显示图片的http链接

      urls: this.data.imgalist0,

      urls: this.data.imgalist1,

      urls: this.data.imgalist2,// 需要预览的图片http链接列表

      })

      },





      错误报告:

      VM1015:1 thirdScriptError 

       sdk uncaught third Error 

       module "pages/index/index/tb/tb.js" is not defined 

       Error: module "pages/index/index/tb/tb.js" is not defined

          at require (http://127.0.0.1:50229/appservice/__dev__/WAService.js:19:19934)

          at http://127.0.0.1:50229/appservice/appservice?t=1534902213371:1065:9

      console.error @ VM1015:1

      (anonymous) @ WAService.js:14

      (anonymous) @ WAService.js:5

      a @ appservice?t=1534902213371:1033

      window.onerror @ VM1015:1

      appservice?t=1534902213371:1068 Wed Aug 22 2018 09:11:44 GMT+0800 (中国标准时间) page 编译错误

      VM1015:1 pages/index/index/tb/tb.js 出现脚本错误或者未正确调用 Page()

      console.error @ VM1015:1

      (anonymous) @ appservice?t=1534902213371:1069

      VM1094:1 Wed Aug 22 2018 09:43:33 GMT+0800 (中国标准时间)  appservice 生成错误

      VM1094:2 file: pages/index/index/tb/tb.js

       unknown: Duplicate declaration "list"

         30 |     let list = this.data.imagelist0.concat(this.data.imagelist1, this.data.imagelist2)

        31 |     urls: list;

      > 32 |       let list = this.data.imagelist1.concat(this.data.imagelist0, this.data.imagelist2)

           |          ^

        33 |     urls: list;

        34 |       let list = this.data.imagelist2.concat(this.data.imagelist1, this.data.imagelist0)

        35 |     urls: list  ; 


      2018-08-22
      回复
    查看更多(6)
登录 后发表内容