先看看效果图:
在这里插入图片描述

鼠标经过列表,字体颜色发生改变
在这里插入图片描述

来看看代码:

<template>
  <div class="content">
    <div class="selectBox" style="width: 400px;">
      <div class="selectBox_show">
        <p>{{ unitName }}</p>
        <i v-on:click.stop="arrowDown"></i>
      </div>
      <div class="selectBox_list" v-show="!isShowSelect">
        <div
          class="selectBox_listLi"
          v-for="(item, index) in dataList"
          :key="item.key"
          @click="select(item, index)"
        >
          {{ item.value }}
        </div>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
export default {
  data() {
    return {
      isShowSelect: false,
      dataList: [
        {key: 1, value: "广州市"},
        {key: 2, value: "天河区"},
        {key: 3, value: "海珠区"},
        {key: 4, value: "荔湾区"},
        {key: 5, value: "番禺区"},
        {key: 6, value: "白云区"},
        {key: 7, value: "黄浦区"},
        {key: 8, value: "增城区"},
        {key: 9, value: "从化区"}
      ],
      unitName:'广州市'
    }
  },
  methods: {
    arrowDown() {
      this.isShowSelect = !this.isShowSelect;
    },
    select(item, index) {
      this.isShowSelect = false;
      this.unitModel = index;
      this.unitName = item.value;
    },
  }
};
</script>
<style lang="scss" scoped>
.content {
  background-color: #001b30;
  height: 100vh;
  .selectBox {
    margin: auto;
    .selectBox_show {
      position: relative;
      p {
        color: #fff;
        font-size: 14px;
        padding-top: 12px;
        padding-left: 10px;
      }
      i {
        position: absolute;
        top: 18px;
        left: 55px;
        width: 0;
        height: 0;
        border-width: 0 8px 8px;
        border-style: solid;
        border-color: transparent transparent #8fdcde;
      }
    }
  }
  .selectBox_list {
    height: 120px;
    width: 80px;
    color: #3c759b;
    background-color: #00355e;
    margin-bottom: 5px;
    text-align: center;
    overflow: auto;
    font-size: 13px;
    .selectBox_listLi {
      cursor: pointer;
    }
    .selectBox_listLi:hover {
      color: #fff;
    }
  }
}
/*修改滚动条样式*/
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background-color: #021348;
}
::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 3px rgba(0.4, 0, 0, 0.3);
  border-radius: 10px;
  background-color: #021348;
}
::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
  background-color: #20307f;
}
</style>
Logo

前往低代码交流专区

更多推荐