收藏
回答

想实现点击一个button出现四张不一样的图片

希望大神们help一下,我设置了很多button,希望点击每一个button各自出现四张不一样的图片。

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

19 个回答

  • .
    .
    2017-08-11

    touchBtn:function(e){这部分打上去(e)有警告信息

    2017-08-11
    有用
    回复
  • .
    .
    2017-08-11

    谢谢啦,但是好像还是不行,可能我哪里弄错了

    2017-08-11
    有用
    回复
  • 银色子弹
    银色子弹
    2017-08-11

    <button class="post" style="margin-top:8%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 1>

    大门

    </button>

    <button class="post" style="margin-top:17%;" bindtap="touchBtn" hover-class="hoverclass" data-id = 2>

    教学楼

    </button>

    <view class="img-box">

            <image class="image-style" src="{{imgArr[0]}}"></image>

            <image class="image-style" src="{{imgArr[1]}}"></image>

            <image class="image-style" src="{{imgArr[2]}}"></image>

            <image class="image-style" src="{{imgArr[3]}}"></image>

    </view>

    . var imgArr = [];


          touchBtn:function(e){

            var data = e.currentTarget.dataset.id;

            if(data == 1){//大门

                imgArr = [];//存储要展示的图片

            }else if(data == 2){//教学楼

                  imgArr = [];//存储要展示的图片

            }

            this.setData({

              imgArr: imgArr,

            })

          }


    2017-08-11
    有用
    回复
  • .
    .
    2017-08-11

     data:{

        imagesrc:"",

      },

          btn_a:function(){

            this.setData({

              imagesrc: "/images/1.png"

            })

          },

          btn_b: function () {

            this.setData({

              imagesrc: "/images/2.png"

            })

          },




      <button class="post" style="margin-top:8%;" bindtap="btn_b" hover-class="hoverclass">大门</button>

        <button class="post" style="margin-top:17%;" bindtap="btn_c" hover-class="hoverclass">教学楼</button>



        <image class="image-style" src="{{imagesrc}}"></image>

    能改改嘛?我赋值了几个片段

    2017-08-11
    有用
    回复
  • 银色子弹
    银色子弹
    2017-08-11

    左边放四个image 用一个view 包起来  右边点击场景切换的时候 控制这个view显示隐藏 给image重新赋值显示新的图片内容 应该就可以了呀

    2017-08-11
    有用
    回复
  • .
    .
    2017-08-11

    就是这样点击一个按钮左边出现四幅图

    2017-08-11
    有用
    回复
  • 银色子弹
    银色子弹
    2017-08-11

    你这个出现四张是怎么显示的 有截图吗 是点击一个按钮 预览一个图片吗?预览的话只能预览一个

    2017-08-11
    有用
    回复
  • .
    .
    2017-08-11

    难点就是我只能弄一张,没办法弄四张

    2017-08-11
    有用
    回复
  • 银色子弹
    银色子弹
    2017-08-11

    这个的难点在哪里?

    2017-08-11
    有用
    回复

正在加载...

登录 后发表内容