UNI-APP_uni-app swiper轮播图自定义指示点样式

r囧r小猫 2022-10-17 06:00 1160阅读 0赞

在这里插入图片描述

  1. <view class="swiper_cent">
  2. <swiper class='u-wrp-bnr' :indicator-dots='false' autoplay='true' interval='3000' duration='1000' circular='true' @change="swiperChange">
  3. <block v-for="(item,i) in swiper" :key="i" >
  4. <swiper-item>
  5. <image :src='item.src' class='u-img-slide' mode='aspectFill'></image>
  6. </swiper-item>
  7. </block>
  8. </swiper>
  9. <view class="swiper_zhishi">
  10. <view :class="swiperKey == i?'view_active':''" v-for="(item,i) in bnrUrl" :key="i"></view>
  11. </view>
  12. </view>
  13. export default {
  14. data() {
  15. return {
  16. swiper:[ //轮播数据
  17. { src:'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1529354343,4008095697&fm=26&gp=0.jpg'},
  18. { src:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1663879126,2733636093&fm=26&gp=0.jpg'},
  19. ],
  20. swiperKey:0, //轮播位置
  21. }
  22. },
  23. onLoad() {
  24. },
  25. methods: {
  26. swiperChange(e){
  27. // console.log(e.detail);
  28. this.swiperKey = e.detail.current
  29. }
  30. }
  31. }
  32. .swiper_cent{
  33. display: flex;
  34. justify-content: center;
  35. border-radius:7rpx;
  36. position: relative;
  37. overflow: hidden;
  38. }
  39. .swiper_zhishi{
  40. display: flex;
  41. align-items: center;
  42. width: 100%;
  43. justify-content: center;
  44. position: absolute;
  45. bottom: 15rpx; view{
  46. width: 29rpx;
  47. height: 4rpx;
  48. background: #FFFFFF;
  49. border-radius: 2rpx;
  50. margin-right: 13rpx;
  51. color: #000;
  52. }
  53. .view_active{
  54. background: #3192FE;
  55. }
  56. }
  57. .u-wrp-bnr {
  58. width: 700rpx;
  59. height: 278rpx;
  60. display: block;
  61. background: #f0f0f0;
  62. border-radius:7rpx;
  63. }
  64. .u-img-slide {
  65. width: 100%;
  66. height: inherit;
  67. }

发表评论

表情:
评论列表 (有 0 条评论,1160人围观)

还没有评论,来说两句吧...

相关阅读