[Vuejs]-Dynamic loading of vue components with vite working on dev but not server

0👍

for a work around I thought "If only I could just load everything in and forget about all this" and that’s what we did.

I made a new components, lets call if ‘fields’. That component simply loads in everything that might be a variable like so

<template>

    <x v-if="field === 'x'" @change="saveAttributes" :attributes="attributes" ></x>
    <y v-if="field === 'y'"  @change="saveAttributes" :attributes="attributes" ></y>

</template>

But from comments and other similar questions on the web it looks like the original way I attempted should work, I must just have something weird going on.

Good luck.

0👍

Another answer that is less of a workaround. @duannx asked me to put the example up on stackblitz and I actually got it working. So this might be a good reference for anyone struggling.

You can change ‘a’ to ‘b’ where I have commented so on app.js to test what wasn’t working on my local machine but is working on stackblitz. Hopefully this can help someone but I think I’m moving on

https://stackblitz.com/edit/vitejs-vite-o9w6cu?file=src%2FApp.vue,src%2Fcomponents%2Fa.vue,src%2Fcomponents%2Fb.vue

Leave a comment