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)

    },
  • 相关阅读:
    Apache Commons介绍(转载)
    MYSQL Nested Join Optimization
    Mysql Nested-Loop Join Algorithms
    jquery eval解析JSON中的注意点介绍
    jspSmartUpload上传下载使用例子
    JavaWeb基础
    (一)Model的产生及处理
    SpringMVC注解@RequestParam全面解析
    @ModelAttribute使用详解
    Spring中Controller和RequestMapping的详解
  • 原文地址:https://www.cnblogs.com/lipuqing180906/p/9602611.html
Copyright © 2011-2022 走看看