我的账户
猩码学苑

专注C++开发菁英教育

亲爱的游客,欢迎!

已有账号,请

如尚未注册?

梁洁---20230110--vue项目第八天

[复制链接]
梁杰,你好 发表于 2023-1-30 23:09:13 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
<template>
  <div class="mysingers">
    <!-- <h1>这是歌手歌手界面</h1>
    "
     -->
    <ScrollView ref="singersw" class="arlistView">
      <ul class="ulist">
        <li v-for="(val, index) in keys" :key="index" :class="val" class="item">
          <h2>{{ val }}</h2>
          <ul>
            <li
              v-for="(item, i) in arList[index].data.artists"
              :key="i"
              class="everyList"
            >
              <img v-lazy="item.img1v1Url" alt="" />
              {{ item.name }}
            </li>
          </ul>
        </li>
      </ul>
    </ScrollView>
    <ul class="keylist">
      <li
        v-for="(val, index) in keys"
        :key="index"
        :class="{ active: cln == index }"
        @click="changview(val)"
      >
        {{ val }}
      </li>
    </ul>
  </div>
</template>

<script>
import { getAllArtist, getAllArtistssss } from "../api/index";
import ScrollView from "../components/ScrollView.vue";
// scrolling
export default {
  name: "MySingers",
  components: {
    ScrollView,
  },
  data() {
    return {
      keys: [],
      arList: [],
      cln: 0,
      topgroup: [],
    };
  },
  created() {
    // let obj = await getAllArtist(); async
    // console.log("created", obj);

    getAllArtistssss().then((res) => {
      this.keys = res.keys;
      this.arList = res.list;
    });
  },
  mounted() {
    this.$refs.singersw.scrolling((y) => {
      // console.log(y);
      this.keys.forEach((v, i) => {
        // console.log();
        let cstr = `li.${v}`;
        let ltop = document.querySelector(cstr).offsetTop;
        // let aatop = this.$refs.singersw.$el.offsetHeight;

        // this.topgroup.push(obj);
        if (ltop <= -y + 200) {
          this.cln = i;
        }
      });
    });
  },
  methods: {
    changview(val) {
      let cstr = `li.${val}`;
      let ltop = document.querySelector(cstr).offsetTop;
      this.$refs.singersw.scrollTo(0, -ltop, 200);
    },
  },
};
</script>

<style scoped lang="scss">
@import "../assets/css/mixin.scss";
.arlistView {
  position: fixed;
  top: 180px;
  left: 0;
  bottom: 0;
  right: 0;
  overflow: hidden;
}
.mysingers {
  position: relative;
  font-size: 30px;
  h2 {
    margin-left: 10px;
    margin-right: 10px;
    font-size: 40px;
    font-weight: 700;
    // widows: 90%;

    // background-color: red;
    @include bgColor();
  }
  .everyList {
    height: 100px;
    width: 100%;
    border-bottom: 1px solid #ccc;
    padding-left: 10px;
    display: flex;
    align-items: center;

    img {
      width: 60px;
      height: 60px;
      border-radius: 30px;
      margin-right: 20px;
    }
  }
}
.keylist {
  position: absolute;
  top: 30px;
  left: 90%;
  font-size: 30px;
  font-weight: 700;
  li {
    margin-top: 10px;
    text-align: center;
    &.active {
      color: red;
      font-size: 40px;
    }
  }
}
.ulist {
  .item:last-child {
    padding-bottom: 150%;
    // height: 100%;
  }
}
</style>


回复

使用道具 举报

关注0

粉丝0

帖子77

发布主题
大家都在学
课堂讨论
一周热帖排行最近7x24小时热帖
关注我们
专注C++菁英教育

客服电话:18009298968

客服时间:9:00-21:00

猩码学苑 - 专注C++开发菁英教育!( 陕ICP备2025058934号-1 )

版权所有 © 陕西菁英数字科技有限公司 2023-2026