Skip to content

Can't get VNode when use named slot #814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MirckMuse opened this issue Mar 11, 2020 · 1 comment
Closed

Can't get VNode when use named slot #814

MirckMuse opened this issue Mar 11, 2020 · 1 comment

Comments

@MirckMuse
Copy link

Version

3.0.0-alpha.8

Steps to reproduce

Create a component named TButton

<template>
  <button><slot/></button>
</template>

Create a component named TPopover

<template>
  <span>
    <div ref="popover" id="tooltip" role="tooltip">
      <slot>{{content}}</slot>
    </div>

    <slot name="reference"/>
  </span>
</template>

<script>
import { onMounted, ref } from 'vue'
export default {
  name: 'TPopover',
  props: {
    content: { type: String, default: '' },
    placement: { type: String, default: 'bottom' },
    showArrow: { type: Boolean, default: true }
  },
  setup (props, { slots}) {
    const popover = ref(null)
    onMounted(() => {
      console.log(slots.reference()[0].el) // Print null, can't get the VNode of button
    })
    return {
      popover
    }
  }
}
</script>

using named slot

<t-popover>
  <div>
    popover content
  </div>
  <template #reference>
	<t-button>button</t-button>
  </template>
</t-popover>

What is expected?

Get the named slot's VNode

What is actually happening?

Get null

@vue-bot
Copy link
Contributor

vue-bot commented Mar 11, 2020

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

@vue-bot vue-bot closed this as completed Mar 11, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants