Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SlotComponent.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. export default {
  2. name: 'BSlotComponent',
  3. props: {
  4. component: {
  5. type: Object,
  6. required: true
  7. },
  8. name: {
  9. type: String,
  10. default: 'default'
  11. },
  12. tag: {
  13. type: String,
  14. default: 'div'
  15. },
  16. event: {
  17. type: String,
  18. default: 'hook:updated'
  19. }
  20. },
  21. methods: {
  22. refresh() {
  23. this.$forceUpdate()
  24. },
  25. isVueComponent() {
  26. return this.component && this.component._isVue
  27. }
  28. },
  29. created() {
  30. if (this.isVueComponent()) {
  31. this.component.$on(this.event, this.refresh)
  32. }
  33. },
  34. beforeDestroy() {
  35. if (this.isVueComponent()) {
  36. this.component.$off(this.event, this.refresh)
  37. }
  38. },
  39. render(h) {
  40. if (this.isVueComponent()) {
  41. const slots = this.component.$slots[this.name]
  42. return h(this.tag, {}, slots)
  43. }
  44. }
  45. }