Skip to content

Commit eddfbf9

Browse files
committed
update
1 parent 54e442a commit eddfbf9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

vuex/App.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
{{ post.title }}
88
</button>
99

10-
<div v-if="store.state.posts.post">
10+
<div v-if="post">
1111
<h1>
12-
{{ store.getters['posts/postTitle'] }}
12+
{{ postTitle }}
1313
</h1>
14-
<p>{{ store.state.posts.post.content }}</p>
14+
<p>{{ post.content }}</p>
1515
</div>
1616
</template>
1717

1818
<script>
19+
import { computed } from 'vue'
1920
import { useStore } from 'vuex'
2021
2122
export default {
@@ -36,8 +37,17 @@ export default {
3637
store.dispatch('posts/fetchPostData', post.id)
3738
}
3839
40+
const post = computed(() => {
41+
return store.state.posts.post
42+
})
43+
44+
const postTitle = computed(() => {
45+
return store.getters['posts/postTitle']
46+
})
47+
3948
return {
40-
store,
49+
postTitle,
50+
post,
4151
fetchPost,
4252
posts,
4353
}

0 commit comments

Comments
 (0)