Open vip30 opened 2 years ago
Found that if change filename to Functional.functional.vue
, it works
Found that if change filename to
Functional.functional.vue
, it works
Yes, we have to rename functional component .vue file
to contain .functional
mark.
So that this lib can detect functional component.
You can customize the mark by functionalComponentFileIdentifier
option :
// where you config to use vue-template-babel-compiler, eg: vue.config.js
.tap(options => {
options.functionalComponentFileIdentifier = 'whateverYouWantToMarkFunctionalComponentFile'
options.compiler = require('vue-template-babel-compiler')
return options
})
Sorry for the inconvenience, I will update Doc to address. Thank you for your feedback~
Have the same problem
Have the same problem
@Mrzhangqc We have to rename functional component
.vue
file to contain .functional
mark.
If you have any good idea, welcome for Pull Request.
We should be able to know if a .vue
file is or not functional component
.
But we can NOT get this from options:
I implement this logic in: https://github.com/JuniorTour/vue-template-babel-compiler/blob/09211ec7ca40b500eb15ea2d2b5233cc74e739cb/src/templateCompiler.js#L33-L34
if this isn't in the documentation / readme, it might be good to add it there
oh nvm, found the doc here https://github.com/JuniorTour/vue-template-babel-compiler/blob/main/doc/Usage.md#1-Functional-Component-Usage
thanks for a great package, and for posting this question / answer- helped me out. thought i'd have to revert my optional chaining. glad i can keep it by just renaming files to .functional
odd that you can't introspect into the component definition at all to find the .functional=true flag
maybe it's different in vue 2 vs. vue 3?
@jakedowns Thanks for your support!
web component
:... end your component file name with .ce.vue: https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue
So currently, I think add mark to file name is an acceptable solution.
But if anyone has any idea, welcome for discussion!
Description
Filename: Functional.vue
Current behavior
Throw error message
Expected behavior
Can be used