TreeTab.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div class="tabList">
  3. <ul class="clearfix">
  4. <li :class="{'curTab':curId==item.id}"
  5. @click="()=>handleTabClick(item.id)"
  6. v-for="item in tab" :key="item.id"
  7. >{{item.name}}<span v-if="curId==item.id"></span></li>
  8. </ul>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. data(){
  14. return {
  15. curId:'1',
  16. tab:[
  17. {name:'化学物质类别',id:'1'},
  18. {name:'治疗学类别',id:'2'},
  19. {name:'药理学类别',id:'3'},
  20. {name:'解剖学类别',id:'4'},
  21. {name:'实验室检查类别',id:'7'},
  22. {name:'辅助检查类别',id:'8'},
  23. ],
  24. }
  25. },
  26. mounted(){
  27. let elSide = document.querySelector('.el-aside'),tabWidth = document.querySelector('.tabList');
  28. window.onresize = function(){
  29. tabWidth = document.querySelector('.tabList')
  30. tabWidth.style.left = elSide.offsetWidth+20+'px'
  31. }
  32. tabWidth.style.left = elSide.offsetWidth+20+'px'
  33. },
  34. methods:{
  35. handleTabClick(id){
  36. this.curId = id
  37. this.$emit('getTreeList',id)
  38. },
  39. }
  40. }
  41. </script>
  42. <style lang="less" scoped>
  43. .tabList {
  44. position: fixed;
  45. top: 100px;
  46. right: 20px;
  47. left: 270px;
  48. z-index: 10;
  49. border-top: 10px solid #dee2ea;
  50. border-bottom: 10px solid #dee2ea;
  51. box-sizing: border-box;
  52. ul {
  53. background-color: #fff;
  54. li {
  55. float: left;
  56. height: 60px;
  57. line-height: 60px;
  58. margin: 0 15px;
  59. box-sizing: border-box;
  60. cursor: pointer;
  61. position: relative;
  62. span {
  63. position: absolute;
  64. bottom: 10px;
  65. left: 0;
  66. width: 100%;
  67. height: 2px;
  68. background-color: #21CBC7;
  69. }
  70. }
  71. .curTab {
  72. color: #48C5D7;
  73. }
  74. }
  75. }
  76. </style>