Skip to content

🐛 [Bug]: vue@2.7.16 下 modal 的 slots 不生效,render函数不太对 #3450

@defghy

Description

@defghy

Version

2.23.0

Vue Version

2.7.16

Link to minimal reproduction

modal的slot不兼容vue2

Step to reproduce

modal的slot对应的render函数如下

  h(
    "div",
    {
      class: "tiny-modal__content",
    },
    defaultSlot
      ? defaultSlot.call(
          this,
          {
            $modal: this,
          },
          h
        )
      : [
          h(
            "div",
            {
              class: "tiny-modal__text",
            },
            typeof message2 === "function"
              ? message2.call(this, h)
              : [message2]
          ),
        ]
  )

这里defaultSlot.call需要用数组格式,否则children是undefined,需要如下格式才行

[
defaultSlot.call(
    this,
    {
      $modal: this,
    },
    h
  )
]

可能vue3这样可以,但是vue2不行

What is expected

No response

What is actually happening

No response

What is your project name

todo

Any additional comments (optional)

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions