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)

    },
  • 相关阅读:
    Fedora 14下安装使用rarlinux wang
    fedora 14 64位安装 flash player wang
    SQL中的 'N/A'含义
    Sql Sever中的replace()函数
    CompletableFuture的实际使用
    Asp.net检测系统是否装有.net环境
    JS与Asp.Net的传值
    JAVASCRIPT加密解密终级指南escape解密/eval加密/Encode加密原理
    在IIS上启用Gzip压缩(HTTP压缩)
    jquery批量上传图片
  • 原文地址:https://www.cnblogs.com/lipuqing180906/p/9602611.html
Copyright © 2011-2022 走看看