index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="accordion-content">
  3. <view class="accordion-mask" :class="[direction,{'fixed':fixed,'hide':hide}]" @click.stop="handle(1)">
  4. <slot name="item">
  5. <view class="accordion-item" @click.stop="handle(2)">
  6. <p :class="direction"></p>
  7. <slot name="cont"></slot>
  8. </view>
  9. </slot>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default{
  15. name:"zhcx-accordion",
  16. props:{
  17. type:{
  18. type:[String,Number],
  19. default:"1"
  20. },
  21. fixed:{
  22. type:[String,Boolean],
  23. default:true
  24. },
  25. direction:{
  26. type:[String],
  27. default:"lf"
  28. }
  29. },
  30. data:()=>{
  31. return{
  32. hide:false
  33. }
  34. },
  35. methods:{
  36. handle(type){
  37. if(type===1){
  38. this.hide=true;
  39. }
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. .accordion-content{
  46. .fixed{
  47. position: fixed;
  48. left: 0;
  49. right: 0;
  50. top: 0;
  51. bottom: 0;
  52. z-index: 9998;
  53. }
  54. .accordion-mask{
  55. background-color: rgba(0,0,0,0.62);
  56. transition: 0.5s;
  57. .accordion-item{
  58. background-color: #fff;
  59. width: 50%;
  60. height: 100%;
  61. }
  62. &.hide{
  63. right: 100%;
  64. overflow: hidden;
  65. &.rt{
  66. left: 100%;
  67. right: -100%;
  68. }
  69. &.top{
  70. left: 0;
  71. right: 0;
  72. bottom:0;
  73. top: 100%;
  74. transition: 0.8s;
  75. }
  76. &.bottom{
  77. top: 0;
  78. bottom:100%;
  79. left: 0;
  80. right: 0;
  81. transition: 0.8s;
  82. }
  83. }
  84. }
  85. }
  86. </style>