sd-column.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. export default defineComponent({
  2. name: 'SdColumn',
  3. props: {
  4. prop: String,
  5. label: String
  6. },
  7. setup(props, {slots}) {
  8. const instance = getCurrentInstance()
  9. let parent = instance.parent
  10. parent.exposed.setStore(123)
  11. console.log(parent.exposed.getStore());
  12. },
  13. render() {
  14. try {
  15. const renderDefault = this.$slots.default?.({
  16. row: {},
  17. column: {},
  18. $index: -1,
  19. })
  20. const children = []
  21. if (Array.isArray(renderDefault)) {
  22. for (const childNode of renderDefault) {
  23. if (
  24. childNode.type?.name === 'ElTableColumn' ||
  25. childNode.shapeFlag & 2
  26. ) {
  27. children.push(childNode)
  28. } else if (Array.isArray(childNode.children)) {
  29. childNode.children.forEach((vnode) => {
  30. // No rendering when vnode is dynamic slot or text
  31. if (vnode?.patchFlag !== 1024 && typeof vnode?.children !== 'string') {
  32. children.push(vnode)
  33. }
  34. })
  35. }
  36. }
  37. }
  38. return h('div', children)
  39. } catch {
  40. return h('div', [])
  41. }
  42. },
  43. })