graceSegmentedControl.nvue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view class="gui-segmented-Control">
  3. <text class="gui-segmented-Control-item" v-for="(item, index) in items" :key="index"
  4. :style="{height:height, lineHeight:height, color:current == index ? '#FFFFFF' : color, backgroundColor:current == index ? color : '#F5F6F8', fontSize:fontSize}" @tap.stop="changeSC" :data-index="index">{{item}}</text>
  5. </view>
  6. </template>
  7. <script>
  8. export default{
  9. props:{
  10. items : {
  11. type : Array,
  12. default : function () {
  13. return new Array()
  14. }
  15. },
  16. height : {
  17. type : String,
  18. default : '60rpx'
  19. },
  20. color : {
  21. type : String,
  22. default : '#3688FF'
  23. },
  24. fontSize : {
  25. type : String,
  26. default : '26rpx'
  27. },
  28. current : {
  29. type : Number,
  30. default : 0
  31. }
  32. },
  33. methods:{
  34. changeSC:function (e) {
  35. this.$emit('change', Number(e.currentTarget.dataset.index));
  36. }
  37. }
  38. }
  39. </script>
  40. <style scoped>
  41. .gui-segmented-Control{flex-direction:row; flex-wrap:nowrap; background-color:#F5F6F8; border-radius:10rpx; padding:6rpx; width:750rpx; flex:1;}
  42. .gui-segmented-Control-item{width:700rpx; text-align:center; flex:1; border-radius:8rpx;}
  43. </style>