zoukankan      html  css  js  c++  java
  • 微信小程序-单选

    wxml
    <view class='taskAll_pic'>
    <view class='titleTxet'>图片</view>
    <view class='picBgInput'>
    <view wx:for='{{changeList}}' wx:for-item='item' class='imgFath' bindtap='changePic' data-index='{{index}}'>
    <image class='changShow' src='{{item.isSeleted==false?item.icon:sleectedIcon}}'></image>
    <image class='changImg' src='{{item.img}}'></image>
    </view>
    </view>
    </view>
     
    js
     
    changeList: [
    { "icon": "/images/attic/round.png", "img": "/images/attic/father.png", 'isSeleted': false },
    { "icon": "/images/attic/round.png", "img": "/images/attic/good.png", 'isSeleted': false },
    { "icon": "/images/attic/round.png", "img": "/images/attic/mather.png", 'isSeleted': false },
    { "icon": "/images/attic/round.png", "img": "/images/attic/my.png", 'isSeleted': false },
    { "icon": "/images/attic/round.png", "img": "/images/attic/tv.png", 'isSeleted': false }
    ],
    // 选择 图片
    changePic(e){
    if (this.data.changeList[e.currentTarget.dataset.index].isSeleted == false){
    this.data.changeList[e.currentTarget.dataset.index].isSeleted = true
    }

    if (this.data.changeList[e.currentTarget.dataset.index].isSeleted == true){
    for (let ii in this.data.changeList){
    //下标不为 e.currentTarget.dataset.index 全为 false
    if ( ii != e.currentTarget.dataset.index){
    this.data.changeList[ii].isSeleted = false;
    }
    }
    }

    this.setData({
    changeList: this.data.changeList,
    icon: this.data.changeList[e.currentTarget.dataset.index].img
    })

    console.log(this.data.icon)

    },
  • 相关阅读:
    2019春第一次实验报告
    2019春第二次实验报告
    第十二周编程总结
    第十一周编程总结
    第十周作业
    C语言II博客作业04
    C语言II博客作业03
    C语言II博客作业02
    C语言II博客作业01
    学期总结
  • 原文地址:https://www.cnblogs.com/lipuqing180906/p/9602611.html
Copyright © 2011-2022 走看看