android - does weex's list have a selected event?
phpcn_u1582
phpcn_u1582 2017-05-16 13:28:43
0
2
675

Like the title, I want to realize that when I click on a cell, that cell will change color to distinguish it from other cells, and it will be a single selection. Or how to get the cell object based on the index in the list

phpcn_u1582
phpcn_u1582

reply all(2)
滿天的星座

Use active pseudo-class in css

<template>
  <p>
    <list class="list">
      <cell
        v-for="(v,i) in rows"
        append="tree"
        :index="i"
        :key="i"
        class="row">
        <p class="item">
          <text class="item-title">row {{v.id}}</text>
        </p>
      </cell>
    </list>
</text>
  </p>
</template>

<style scoped>
  .list {
    height:850px
  }
  .count {
    font-size: 48px;
    margin:10px;
  }
  .indicator {
    height: 40px;
    width: 40px;
    color:#45b5f0;
  }
  .row {
    width: 750px;
  }
  .item {
    justify-content: center;
    border-bottom-width: 2px;
    border-bottom-color: #c0c0c0;
    height: 100px;
    padding:20px;
  }
  .item:active {
     background-color: #00BDFF;
   }
  .item-title {
  }
</style>

Please refer to http://weex.apache.org/cn/ref...

过去多啦不再A梦

To achieve a radio-select-like effect, you can probably do this:
Use the selected field of the current row to determine whether it is selected, thereby changing the background-color
Dom structure as follows:

<list>
<cell v-for="(item,index) in listData" v-bind:style="{'background-color':(item.selected?'#dddddd':'#ffffff')}" @click="onSelected(item,index)">
<p>
<text>{{item.text}}</text>
</p>
</cell>
</list>

The js structure is as follows:

data: {
    "listData": [
                {'text': '开发者头条', selected: false},
                {'text': '腾讯新闻', selected: false},
                {'text': '搜狐娱乐', selected: false},
                {'text': '优酷视频', selected: false}
            ]
},
methods:{
    "onSelected":function(item,index){
         if (item.selected) {
           this.listData[index].selected = false;
         } else {
           this.listData[index].selected = true;
         }
    }
}

Hope it can help you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template