Rohit Bajaniya
Rohit Bajaniya

Reputation: 41

The `render` function is not replacing slot content

I am using vue 2.0.

I want to generate this template:

<Poptip placement="right" width="400">
    <Button type="ghost">click 激活</Button>
    <div class="api" slot="content">my content</div>
</Poptip>

Using the render function:

render: (h, params) => {
  return h('Poptip', {
    props: {
      placement: 'right'
    }
  }, [
    h('Button', {
      props: {
        type: 'ghost'
      }
    }, 'Edit'),
    h('div', {
      props: {
        slot: 'content'
      }
    }, 'My content')
  ])
}

Using the template works perfectly. But, when I use the render function, the slot's content is not replaced with my content.

Upvotes: 2

Views: 665

Answers (1)

thanksd
thanksd

Reputation: 55664

You are specifing a prop named slot with value content:

h('div', {
  props: {
    slot: 'content'
  }
}, 'My content')

To simply specify a slot named content:

h('div', {
  slot: 'content'
}, 'My content')

See the documentation.

Upvotes: 2

Related Questions