index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="page">
  3. <template v-if="list.length">
  4. <div class="item" :style="{'width':'calc(100% / '+list.length+')'}"
  5. :class="{'active':idx===index}"
  6. v-for="(item,index) in list"
  7. :key="item.dictValue"
  8. @tap="changeType(index,item.dictValue)">
  9. {{item.dictLabel}}
  10. </div>
  11. </template>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. props:{
  17. list:{
  18. typeof:Array,
  19. default:[]
  20. }
  21. },
  22. data(){
  23. return {
  24. idx:0
  25. }
  26. },
  27. methods:{
  28. changeType(index,value){
  29. this.idx = index;
  30. this.$emit('changeType',value)
  31. }
  32. }
  33. }
  34. </script>
  35. <style scoped lang="less">
  36. .page{
  37. height: 102rpx;
  38. display: flex;
  39. background: #fff;
  40. .item{
  41. height: 100%;
  42. position: relative;
  43. display: flex;
  44. align-items: center;
  45. justify-content: center;
  46. font-family: PingFangSC, PingFang SC;
  47. font-weight: 400;
  48. font-size: 28rpx;
  49. color: #1D2129;
  50. line-height: 40rpx;
  51. &.active{
  52. color: #198CFF;
  53. font-size: 32rpx;
  54. font-weight: bold;
  55. &::after{
  56. content: '';
  57. width: 36rpx;
  58. height: 8rpx;
  59. border-radius: 4rpx;
  60. background: #198CFF;
  61. position: absolute;
  62. left: 50%;
  63. margin-left: -18rpx;
  64. bottom: 8rpx;
  65. }
  66. }
  67. }
  68. }
  69. </style>