Created
October 29, 2020 19:38
-
-
Save shershen08/aad23cb695db4299509494b5f9c9659b to your computer and use it in GitHub Desktop.
vuex4 + filtering stuff in component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup(props) { | |
const store = useStore() | |
const user = computed(() => { | |
return store.getters.authUser | |
}) | |
const posts = computed(() => { | |
return store.getters.posts | |
}) | |
const userPosts = computed(() => { | |
//console.log(user, posts) | |
const res = [] | |
for (const key in Object.keys(posts.value)) { | |
res.push(posts[key]) | |
} | |
return res | |
//.value.filter(post => post.userId == user.userId) | |
}) | |
const userPostsCount = watch(userPosts, (userPosts) => userPosts.lenth) | |
return {userPosts, user, userPostsCount} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment