bookshelf-bookList.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view class="content">
  3. <view class="book-list">
  4. <view class="book-list__item" v-for="(item,index) in book_list" :key="index"
  5. @click="clickBookItem(item,index)">
  6. <image class="book-list__item__book-cover" :src="item.book_cover" mode="aspectFill"></image>
  7. <view class="book-list__item__book-name">
  8. {{item.book_name}}
  9. </view>
  10. <view class="book-list__item__book-info">
  11. 0章 / 500章
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. import { ref } from 'vue';
  19. import { BookshelfData } from '../../stores/bookshelfManager';
  20. import { book_item_data } from '../../data/data';
  21. let book_list = ref(BookshelfData().getBookList())
  22. console.log('BookshelfData111 =',book_list.value)
  23. function clickBookItem(book_data:book_item_data, index:number) {
  24. if(index>0) {
  25. book_list.value.splice(index,1)
  26. book_list.value.unshift(book_data)
  27. }
  28. }
  29. </script>
  30. <style lang="scss">
  31. .content{
  32. display: flex;
  33. flex-direction: column;
  34. .book-list{
  35. display: flex;
  36. flex-direction: row; //横向排列
  37. flex-wrap: wrap; //换行排列
  38. padding: 1% 2%;
  39. // background-color: red;
  40. &__item {
  41. display: flex;
  42. flex-direction: column;
  43. margin: 2% 2%;
  44. width: 46%;
  45. align-items: center;
  46. // background-color: purple;
  47. &__book-cover{
  48. width: 300rpx;
  49. height: 400rpx;
  50. }
  51. &__book-name{
  52. margin-top: 10rpx;
  53. }
  54. &__book-info{
  55. margin-top: 10rpx;
  56. }
  57. }
  58. }
  59. }
  60. </style>