diy-style-contain.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template id="diy-style-contain">
  2. <div class="diy-style-contain" :style="containStyle">
  3. <div class="flex flex-y-center flex-x-sw" :style="defaultStyle">
  4. <div v-if="showTitle" class="dsc-title" :style="titleStyle">{{title}}</div>
  5. <div>
  6. <slot name="right"></slot>
  7. </div>
  8. </div>
  9. <slot></slot>
  10. </div>
  11. </template>
  12. <script>
  13. /**
  14. * 样式容器组件
  15. *
  16. */
  17. Vue.component('diy-style-contain', {
  18. template: '#diy-style-contain',
  19. name: 'diy-style-contain',
  20. props: {
  21. showTitle: {
  22. type: Boolean,
  23. default: true,
  24. },
  25. title: {
  26. type: String,
  27. default: () => "标题"
  28. },
  29. titleStyle: {
  30. type: Object,
  31. default: () => {}
  32. },
  33. containStyle: {
  34. type: Object,
  35. default: () => {}
  36. },
  37. },
  38. computed: {
  39. defaultStyle() {
  40. var obj = {}
  41. if (this.showTitle) {
  42. obj = {
  43. margin: "0 0 20px"
  44. }
  45. }
  46. return obj
  47. },
  48. }
  49. });
  50. </script>
  51. <style scoped>
  52. .diy-style-contain {
  53. position: relative;
  54. padding: 20px;
  55. }
  56. .dsc-title {
  57. font-size: 14px;
  58. font-family: PingFang SC;
  59. font-weight: bold;
  60. color: #333333;
  61. }
  62. .flex {
  63. display: flex;
  64. }
  65. .flex-y-center {
  66. align-items: center;
  67. }
  68. .flex-x-sw {
  69. justify-content: space-between;
  70. }
  71. </style>