core: Methods exposed with defineExpose are not available on custom element

Version

3.2.31

Reproduction link

stackblitz.com

Steps to reproduce

Open repro and you should see ‘hello’ in the console instead of Uncaught TypeError: ce.value.hello is not a function

What is expected?

Methods exposed with defineExpose are available on given component instance

What is actually happening?

They are not exposed

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

facing the same issue, temporary workaround to access the exposed method via $.exposed, e.g.

const myRef = ref()
// <myElement ref="myRef"></myElement>

myRef.value.$.exposed.ExposedMethod()

I created a PR @LinusBorg #6256

I too have this problem but I got to say that it’s not consistent. Some components work and other don’t. I can’t put a finger on a reason why. They all use defineExpose normally.

It seems to affect components that are conditionally rendered via a v-if but the stackblitz example does not do this, so I have no clue why this is happening.

Any progress on that over-a-year-old shortcoming of Vue’s implementation of webcomponents? Is that ever going to land in Vue or should we just create and use a fork to get it implemented?

closed via #6256