CusTabs.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="tabs">
  3. <div :class="{ 'tab-selected': active == item.value }" v-for="item in tabs" :key="item.value"
  4. @click="tabClick(item)">{{ item.name }}</div>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: 'CustomTabs',
  10. props: {
  11. tabs: {
  12. type: Array,
  13. default: () => {
  14. return []
  15. }
  16. },
  17. active: {
  18. type: String | Number,
  19. default:null
  20. }
  21. },
  22. data () {
  23. return {
  24. };
  25. },
  26. mounted () { },
  27. methods: {
  28. tabClick (item) {
  29. this.$emit('update:active', item.value)
  30. this.$emit('tab-click', item)
  31. }
  32. }
  33. }
  34. </script>
  35. <style lang='scss' scoped>
  36. .tabs {
  37. display: flex;
  38. >div {
  39. padding: 2px 8px;
  40. background: #184770;
  41. color: #C1D8E3;
  42. cursor: pointer;
  43. border: none;
  44. font-size: 16px;
  45. &:first-of-type {
  46. border-radius: 4px 0 0 4px;
  47. }
  48. &:last-of-type {
  49. border-radius: 0 4px 4px 0;
  50. }
  51. }
  52. .tab-selected {
  53. background: #fff;
  54. color: #000;
  55. border-radius: 4px !important;
  56. }
  57. }
  58. </style>