<template>
  <div class="person-list">
    <div
      v-for="(item, index) in list"
      :key="index"
      :class="`${item == curName ? 'on' : ''}`"
       @click="handleClick(item)"
      >
      <img src="@/assets/images/location.png"/>
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PersonList',
  data() {
    return {
      curName: null,
      list: [
        '张三',
        '李四',
        '王五',
        '赵柳',
        '陈琦',
        '周八',
        '郑九',
        '石十',
        '赵二',
      ]
    }
  },
  methods: {
    handleClick(name) {
      this.curName = name
      this.$emit('select', name)
    },
    reset() {
      this.curName = null
    }
  },
}
</script>

<style lang="stylus" scoped>
.person-list
  display flex
  flex-wrap wrap
  width 100%
  height 100%
  >div
    display flex
    align-items center
    width 33.3%
    padding 0.5rem 1rem
    cursor pointer
    &.on
      $selected()
    img
      width 1rem
      margin-right 0.8rem
    span
      color #fff
</style>
