gui-accordion-card.vue 921 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view>
  3. <view
  4. hover-class="gui-tap"
  5. @tap="toggle">
  6. <slot name="title"></slot>
  7. </view>
  8. <view
  9. class="gui-fade-in gui-accordion-card-body"
  10. v-if="show">
  11. <slot name="body"></slot>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default{
  17. name : 'gui-accordion-card',
  18. props : {
  19. status : {
  20. type : Boolean,
  21. default : false
  22. }
  23. },
  24. data() {
  25. return {
  26. show : false
  27. }
  28. },
  29. mounted : function(){
  30. this.show = this.status;
  31. },
  32. watch : {
  33. status : function(val){
  34. this.show = val;
  35. }
  36. },
  37. methods : {
  38. toggle : function(){
  39. if(this.show){
  40. this.close();
  41. }else{
  42. this.open();
  43. }
  44. },
  45. open : function(){
  46. this.show = true;
  47. this.$emit('open');
  48. },
  49. close : function () {
  50. this.show = false;
  51. this.$emit('close');
  52. }
  53. },
  54. emits : ['open', 'close']
  55. }
  56. </script>
  57. <style scoped>
  58. .gui-accordion-card-body{padding-bottom:10rpx;}
  59. </style>