Sidebar.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div>
  3. <ul class="sidebar">
  4. <li v-if="list.length<=0">暂无数据</li>
  5. <li @click="handleItem(item)" :class="{active:item.id==activeId}" v-for="(item,i) in list" :key="i">{{item.name}}</li>
  6. </ul>
  7. <slot name="bottom"></slot>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. props:{
  13. list:{
  14. type:Array,
  15. default:()=>{
  16. return []
  17. }
  18. },
  19. activeId:{
  20. type:String,
  21. default:''
  22. }
  23. },
  24. methods:{
  25. handleItem(item){
  26. this.$emit('handleItem',item)
  27. }
  28. }
  29. }
  30. </script>
  31. <style lang="less" scoped>
  32. .sidebar{
  33. border: .04rem solid #9E9E9E;
  34. max-width: 18.42rem;
  35. min-width: 10rem;
  36. li{
  37. overflow: hidden;
  38. text-overflow:ellipsis;
  39. white-space: nowrap;
  40. line-height: 2.08rem;
  41. height: 2.08rem;
  42. padding: 0 .42rem 0 1rem;
  43. position: relative;
  44. font-size: 1rem;
  45. cursor: pointer;
  46. color: #fff;
  47. background-color: #9e9e9e;
  48. text-align: left;
  49. &:hover{
  50. background-color: @theme;
  51. color: #F5B55F;
  52. }
  53. }
  54. .active{
  55. font-weight: bold;
  56. color: #F5B55F;
  57. background-color: @theme;
  58. }
  59. }
  60. </style>