Vue: v-show is not working for functional component

Created on 29 May 2018  路  5Comments  路  Source: vuejs/vue

Version

2.5.16

Reproduction link

https://jsfiddle.net/3h7c204p/5/

Steps to reproduce

simply put v-show="false" at functional component

What is expected?

component not visible

What is actually happening?

component still visible


wrapping it with additional div is workaround for now.
i guess this is not intended

Most helpful comment

yes

All 5 comments

with functional components you need to pass down the context.data to createElement:

  render: function(createElement, context) {
    console.log('Rendering Foo')
    return createElement({
      template: context.props.foo
    }, context.data)

@posva Thank you for your answer
but, actually i used only <template functaionl> and doesn't have render function in my real code (used single file component)
so is this vue-loader related problem?

yes

Workaround: use v-if instead of v-show.

I use v-if in combination with the component as a replacement for v-show - especially when there are potentially many of these components on the page.

Was this page helpful?
0 / 5 - 0 ratings