关于image?

小程序 文章 2021-04-01 11:02 376 0 全屏看文

AI助手支持GPT4.0

关于image?About image?

关于image?

image组件无法显示图片,我设置了一些样式,然后图片地址是后端获取的,只有点开了图片之后才会正常显示是为什么

 <image class="{{index==xindex?'imageBanner':'imageBanner_small'}}data-index="{{index}}data-item="itembindtap="clickImgsrc="/uploads/cj/article/2021/04/01/f2b9489db529658d9122e50985cd3c3c.jpgwx:if="{{item.length>0}}"></image>

clickImg(res){

    console.log(res)

    var num=res.currentTarget.dataset.index

   wx.previewImage({

    urls:[this.data.banner[num]]

   })

}

点开了功能是显示原图

The image component can't display the image. I set some styles, and then the image address is obtained from the back end. Only when the image is opened can it be displayed normally. Why < image class = {{index = = xindex?'imagebanner ':'imagebanner'_ small'}}" data-index="{{index}}" data-item="item" bindtap="clickImg" src="/uploads/cj/article/2021/04/01/f2b9489db529658d9122e50985cd3c3c.jpg" wx:if="{{ item.length >0}}"> clickImg(res){ console.log (res) var num= res.currentTarget.dataset .index wx.previewImage ({ urls:[ this.data.banner The function is to display the original image

回答:

this:

你这个item是什么

Clover_Xu:看我的回复,补充了
Clover_Xu:

<swiper class='bannerSwiperprevious-margin="54rpxnext-margin='54rpxindicator-dots="trueindicator-color='#B5B5B5indicator-active-color='#fffinterval='3000duration='500bindchange='onChangecircular='true'>

      <block wx:for="{{banner}}wx:key="index">

        <swiper-item>

          <image class="{{index==xindex?'imageBanner':'imageBanner_small'}}data-index="{{index}}data-item="itembindtap="clickImgsrc="/uploads/cj/article/2021/04/01/f2b9489db529658d9122e50985cd3c3c.jpgwx:if="{{item.length>0}}"></image>

        </swiper-item>

      </block>

    </swiper>

这是补充的内容,是一个轮播图


Clover_Xu:data: {
   
    banner: [src, src1,src2],
    xindex: 0,
}
😮😮:

你的item是什么东西啊

Mr.Zhao:

没理解

Clover_Xu:就是我设置了一个轮播图,但是不显示,只有点图片后才能正常显示
Mr.Zhao:跟没说一样,写个代码片段出来
Clover_Xu:看回复,已补充
Mr.Zhao:看回复?你逗大家玩呢?banner: [src, src1,src2]  这个咋运行?
Clover_Xu:我后面是用setdata赋值,这个不用管,后面banner里有地址,点开预览也是可行
Clover_Xu:看问题上贴的图,我有必要逗大家玩?我是测试过,banner里面有值才问的问题

-EOF-

AI助手支持GPT4.0