import a dynamic pinia store and vue components from a reference #2398
Unanswered
hquinterost
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm developing an app with Quasa V2 framework, vue, vite, pinia, and <script setup> format. I got a basicList.vue component that get all its control attributes and properties from a pinia store called oTable. In my vue component I import the right pinia store and i get a full crud working for that table. Validations calls are pinia actions. Pinia store does every crud actions and calls to the backend.
I have almost 60 reference tables on my app. So, I want to reuse this basicTable
In order to do that, in my route list I added a prop with the table name and i read it in basicList <script setup>.
If the user select "client" table from the menu. The router calls basicList.vue with "tableName" = "client" prop.
An I have to import the pinia store and the edition child component for the client table. I'm doing that this way:
import { tableStore } from "stores/tables/client.js";
const oTable = tableStore();
const editionComponent = defineAsyncComponent(() =>
import("./ClientItem.vue")
);
This works fine, but i want to make this using the tableName prop instead to a literal string with the table name.
Something like this:
import { tableStore } from "stores/tables/${tableName}.js";
const oTable = tableStore();
const editionComponent = defineAsyncComponent(() =>
import("./${tableName}Item.vue")
);
Unfortunelly, this approach didn´t work. At this points, i don't know how to solve it. Because imports happend at the compile time, and tableName is available at the runtime.
I'll appriciate any help or walkaround on this.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions