網站搜尋
我有一個 <script setup> 區塊,在其中我導入了我的 testStore,但是每當我想在我的 Vue 文件中的某個地方使用 this.testStore.name 時,Vetur 就會給我這個錯誤:
Property 'testStore' does not exist on type 'CreateComponentPublicInstance<{ [x: string &am 閱讀更多 →
我正在這樣使用 Vue 3 的 Composition API:
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(() => (isLoad 閱讀更多 →
我有一個 Nuxt3 項目,裡面有一個位於 server/api/<api-endpoints> 的 Api。在某個端點裡,當我嘗試使用 Pinia Store 時,出現了如下錯誤:
或者當我嘗試從 composables 訪問一個可組合函數時,它無法定義任何變量(說 xxx 未定義,即使它在組件中可以運行,所以它在函數中根
閱讀更多 →
我在將 TypeScript 添加到 Pinia 儲存時遇到了一些問題,所以我想知道我該如何解決這個問題,這個專案使用的是 Pinia:^2.0.16 和 Vue:3.2.37
這是錯誤:
類型 '{}' 缺少類型 'Order' 的以下屬性:id、user_id、total、user、products
import type { ShoppingCart } from '@/Models/ShoppingCart' import type { Product } from '@/Model 閱讀更多 →
我正在使用 Vue 3 搭配 Pinia;我有一個用來對我的 API 發送請求的 API 服務,我已經將它作為屬性添加,以便在我所有的 store 中可用,如下所示:
main.ts:
import { http } from "@/services/http"; const store = createPinia(); store.use(({ store }) => { store.http = http }) 閱讀更多 →
我正在使用 Vue 3 和 Pinia,並且想在我的 Pinia 儲存中使用組合式 API。給定以下示例儲存
export const useMyStore = defineStore("my", () => { const currentState = ref(0); return { currentState }; } );我可以直接修改 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); this.loadin 閱讀更多 →
我在以下程式碼中遇到一個奇怪的錯誤: Property 'length' does not exist on type '{ [RefSymbol]: true; }'.
但是當我在 getCount 函數中檢查 foo 的類型時,我的 IDE 告訴我它的類型是 Foo[]。我哪裡做錯了?
import { defineStore } from 'pinia'; import { useStorage } from '@vueuse/core'; interface Foo {} e 閱讀更多 →
我正在實作一個認證商店(使用 Firebase),並且根據認證狀態我想將使用者導向登入頁面或已登入頁面。
我基本上是想完成這個:https://github.com/dannyconnell/vue-composition-api-course/blob/module-23/vue-composition-api-noteballs/src/stores/storeAuth.js
但是在 TypeScript 中。
在我的 main.ts 中,我確實宣告了 store 為屬性:
const app = createApp(App); const pinia = 閱讀更多 →
我有一家商店。
export const useGameStore = defineStore("game", { state: () => gameBaseState, getters: { foundMarkers(state): Marker[] { return state.markers.filter((m) => m.found); }, ... }, actions: { closeAll 閱讀更多 →