vetur icon indicating copy to clipboard operation
vetur copied to clipboard

Add support for functional components

Open renestalder opened this issue 5 years ago • 5 comments

  • [x] I have searched through existing issues
  • [x] I have read through docs
  • [x] I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.21.0
  • VS Code version: `.34.0

Problem

If functional components are defined in Single File Components, one has to access the Vue instance differently than in the case of a non functional component.

For example, $slots is going to be slots().

Vetur currently doesn't recognize if one is using functional components on a template.

Screenshot 2019-05-27 at 15 39 30

Reproducible Case

  1. Define a .vue component and add the functional tag to the property.
  2. Add property acces e.g. props.<propertyName> or slots e.g. slots().default. The build will work and the app will work in run time. But Vetur shows an error.

Additional information:

  • https://vue-loader.vuejs.org/guide/functional.html
  • https://vuejs.org/v2/guide/render-function.html#Functional-Components

Similar issues

  • #805

renestalder avatar May 27 '19 13:05 renestalder

FYI: <template functional> will be dropped in Vue v3. https://github.com/vuejs/rfcs/pull/27

ktsn avatar May 28 '19 07:05 ktsn

Interesting. Thanks for the link.

It's on "Request for comment" so we cannot yet be sure it will be dropped but it's a fair point to say that one should rather prepare for v3.

renestalder avatar May 28 '19 08:05 renestalder

Yeah, in any cases I'll investigate how we can support it in Vetur.

ktsn avatar May 28 '19 08:05 ktsn

@ktsn I feel like that's a shot into the dark. It now seems pretty clear that functional templates are dropped. Only functional components created via scripts will be available, with the reason that there will be no real performance difference between non functional and functional.

So, from my point view, that's not something that should be tackled at all and can be closed.

renestalder avatar Nov 21 '19 10:11 renestalder

This is very much needed IMHO, right now it just throws an error that:

Property 'props' does not exist

Which is problematic, and in the way.

At least a workaround would be workable.

douglasg14b avatar Dec 12 '21 03:12 douglasg14b