小编Vue*_*ue3的帖子

为什么计算属性在我的 Vue 3 应用程序中不具有反应性?

问题

\n

\xe2\x9c\x85 Vue 2: \n计算属性在 vuex 存储突变后更新。

\n

\xe2\x9d\x8c Vue 3: \nvuex 存储突变后计算属性不会更新。

\n

Vuex 4

\n

目的:从 Firestore 获取帖子。添加到“postsArray”。进行突变。

\n

注意:函数“getNextPosts”是从允许无限滚动的(工作)交叉观察器调用的。

\n
const postsArray: Array<string> = [];\nconst vuexStore = createStore({\n  state: {\n    posts: []\n  },\n  actions: {\n    // See https://firebase.google.com/docs/firestore/query-data/query-cursors#paginate_a_query\n    getFirstPosts({ commit }) {\n      const getFirstPosts = async () => {\n        const firstPostsQuery = firestore.collection("posts").limit(3);\n\n        // Get FIRST posts.\n        const firstPosts = await firstPostsQuery.get();\n\n        // Add to postsArray.\n        for (const doc of firstPosts.docs) {\n …
Run Code Online (Sandbox Code Playgroud)

firebase vue.js vuex vuejs3 vuex4

14
推荐指数
1
解决办法
4197
查看次数

标签 统计

firebase ×1

vue.js ×1

vuejs3 ×1

vuex ×1

vuex4 ×1