vue 2 + webpack migration to vue 3 + vite (inline templates) #9466
Unanswered
MrPels
asked this question in
Help/Questions
Replies: 2 comments
-
Response #2 |
Beta Was this translation helpful? Give feedback.
0 replies
-
vue-3 slot is :slot="slotname" <hello-world v-slot="{ variable }" :slot="slotname">
<h2 v-if="!changeText">Hello from inline template! {{ combinedText }}</h2>
<h2 v-else>done!</h2>
<button class="btn btn-primary" v-on:click="logTest">click</button>
<hello></hello>
</hello-world> nesty component two declaration your component is auto props |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So as the title say i am trying to migrate my code base over to vue 3 + vite. One of the biggest challenges is how inline templates has changed in vue 3, which is quite a challenge to say the least.
I have been following the migration guidelines from this article
https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html
and are going with the "option 2" approach. (as option 1 does not seem to be working and all examples i can find on jsfiddle is broken).
Current status:
As far as i can gather from the migration guide the following example is how you now use what is considered inline templates.
HelloWorldSlotTemplate.Vue
You create a default slot in the template section, and expose what you want to render / call in the html. (you did not need to do this in vue 2 however, and all advice on this part is very welcome).
HelloWorld.Vue
Then i use it on some html page like so:
The problem i am experiencing is the locale registered component does not render but everything else does and i get a weird warning in my browser console.
[Vue warn]: Failed to resolve component: hello
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
at
I have tried what it suggest, but it does not work. I am wondering why it think of "hello" as a custom element, and not a vue component ?
My goal is to get it the local registered component to render, but i am not finding alot of examples on people using inline templates in generel in vue 3, so i am hoping someone with more vue 3 experience than me can enlighten me on the topic / problem.
The only note worthy thing to mention with my vite setup is i override "vue" with "vue.esm-bundler.js" to get the runtime compilation for templates. It enables me to mix and match static html with the vue code, which is a requirement due to some component needing to change their template sections html entirely based on brand specific project they are used in. And due to a lot of legacy css/html structure they deviate alot per project.
If more information is needed i will be more than willing to provide it.
Beta Was this translation helpful? Give feedback.
All reactions