יש לי בלוק <script setup> שבו אני מייבא את testStore שלי אבל כל פעם שאני רוצה להשתמש ב-this.testStore.name במקום כלשהו בקובץ ה-vue שלי, vetur נותן לי את השגיאה הזו:
Property 'testStore' does not exist קרא עוד →
אני משתמש ב-Composition API של Vue 3 כך:
store.ts
import { ref, Ref } from 'vue'; import { defineStore } from 'pinia'; export const useStore = defineStore('store', () => { const isLoading: Ref<boolean> = ref(true); function init() { isLoading.value = true; setTimeout(() => קרא עוד →
יש לי פרויקט Nuxt3 עם API ב-server/api/<api-endpoints>. בתוך נקודת קצה, כשאני מנסה להשתמש ב-Pinia Store זה מציג את ההודעה:
או כאשר אני מנסה לגשת לפונקציה קומפוזבילית מ-co
קרא עוד →
יש לי כמה בעיות כשאני מוסיף TypeScript לחנות Pinia, אז הייתי רוצה לדעת איך אני יכול לפתור את הבעיה הזו, הפרויקט הזה משתמש ב-Pinia:^2.0.16 ו-Vue:3.2.37
זו השגיאה:
הסוג '{}' חסר את התכונות הבאות מהסוג 'Order': id, user_id, total, user, products
impor קרא עוד →
אני משתמש ב-Vue 3 עם Pinia; יש לי שירות API שמשמש לביצוע בקשות ל-API שלי, הוספתי אותו כמאפיין כדי שיהיה זמין בכל החנויות שלי, כך:
main.ts:
import { http } from "@/services/http"; const store = createPinia(); store.use(({ sto קרא עוד →
אני משתמש ב-Vue 3 עם Pinia ורוצה להשתמש ב-Composition API בתוך החנויות שלי ב-Pinia. בהתחשב בדוגמת החנות הבאה
export const useMyStore = defineStore("my", () => { const currentState = ref(0); return { currentState }; קרא עוד →יש חנות כזו כאן :
interface Task { id?: string; name: string; done: boolean; } interface TodoState { tasks: Task[]; loading: boolean; } export const useTodoStore = defineStore({ id: 'todo', state: (): TodoState => ({ tasks: [], loading: false, }), getters: {}, actions: { async addTask(name: string): Promise<void> { this.loading = true; this.tasks.push({ name, done: false, id: generateID() }); await sleep(200); th קרא עוד →
אני מקבל שגיאה מוזרה בקוד הבא: Property 'length' does not exist on type '{ [RefSymbol]: true; }'.
אבל כשאני בודק את סוג ה-foo בפונקציה getCount, ה-IDE שלי אומר לי שהוא מהסוג Foo[]. מה אני עושה לא נכון?
import { defineStore } from 'pinia'; import קרא עוד →
אני מיישם חנות אימות (עם Firebase) ובהתאם לאימות אני רוצה לנתב את המשתמש שלי לדף הכניסה/הדף המחובר.
ביסודו של דבר אני מנסה להשיג את זה: https://github.com/dannyconnell/vue-composition-api-course/blob/module-23/vue-composition-api-noteballs/src/stores/storeAuth.js
אבל ב-TypeScript.
בקובץ main.ts של
קרא עוד →
יש לי חנות.
export const useGameStore = defineStore("game", { state: () => gameBaseState, getters: { foundMarkers(state): Marker[] { return state.markers.filter((m) => m.found); }, ... }, actions: { clos קרא עוד →