find.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="cx-find">
  3. <!-- <div class="bannerBox">
  4. <div class="imgBox">
  5. <img class="bannerImg" v-for="(item, index) in imgArr" :key="item" :src="item" v-show="index == nowIndex">
  6. </div>
  7. <div class="circleBox">
  8. <p v-for="(item, index) in imgArr" :key="index" :class="(index == nowIndex) ? 'selected' : 'bannerCircle'"></p>
  9. </div>
  10. </div> -->
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. nowIndex: 0,
  18. timeObj: {},
  19. imgArr: []
  20. }
  21. },
  22. onLoad() {
  23. setTimeout(() => {
  24. this.imgArr = [
  25. '../../static/images/headPic1.jpg',
  26. '../../static/images/headPic2.jpg',
  27. '../../static/images/headPic3.jpg',
  28. '../../static/images/headPic4.jpg',
  29. '../../static/images/headPic5.jpg',
  30. '../../static/images/avart.jpg',
  31. '../../static/images/avart2.jpg'
  32. ]
  33. }, 1000);
  34. // this.autoPlay();
  35. // const obj = new Map([['id', 101], ['name', 'admin'], ['age', 18], ['sex', '男']]);
  36. // for(const [key, value] of obj) {
  37. // console.log(`Key: ${key}, Value: ${value}`);
  38. // }
  39. //判断当前环境:开发环境/生产环境
  40. // if (process.env.NODE_ENV === 'development') {
  41. // console.log('开发环境');
  42. // } else {
  43. // console.log('生产环境');
  44. // }
  45. },
  46. methods: {
  47. // autoPlay() {
  48. // let that = this;
  49. // for(let i=0; i<this.imgArr.length; i++) {
  50. // this.imgArr[i] = this.nowIndex;
  51. // };
  52. // if (this.nowIndex == 0) {
  53. // this.timeObj = setInterval(() => {
  54. // that.nowIndex++;
  55. // }, 2500);
  56. // };
  57. // if (this.nowIndex == this.imgArr.length) {
  58. // clearInterval(this.timeObj);
  59. // this.nowIndex = 0;
  60. // };
  61. // }
  62. }
  63. }
  64. </script>
  65. <style lang="less">
  66. .cx-find {
  67. .bannerBox {
  68. margin: 10rpx 5%;
  69. position: relative;
  70. width: 90%;
  71. height: 350rpx;
  72. .imgBox {
  73. width: 100%;
  74. height: 100%;
  75. .bannerImg {
  76. width: 100%;
  77. height: 100%;
  78. }
  79. }
  80. .circleBox {
  81. position: absolute;
  82. bottom: 0;
  83. left: 0;
  84. margin-left: 162rpx;
  85. width: 350rpx;
  86. height: 12rpx;
  87. display: flex;
  88. p {
  89. margin-left: 8rpx;
  90. justify-content: center;
  91. margin-top: 1rpx;
  92. float: left;
  93. width: 40rpx;
  94. height: 10rpx;
  95. }
  96. }
  97. }
  98. .bannerCircle {
  99. background: rgba(0, 0, 0, .3);
  100. }
  101. .selected {
  102. background: rgba(208, 2, 27, .7);
  103. }
  104. }
  105. </style>