File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 7
7
{{ post.title }}
8
8
</button >
9
9
10
- <div v-if =" store.state.posts. post" >
10
+ <div v-if =" post" >
11
11
<h1 >
12
- {{ store.getters['posts/ postTitle'] }}
12
+ {{ postTitle }}
13
13
</h1 >
14
- <p >{{ store.state.posts. post.content }}</p >
14
+ <p >{{ post.content }}</p >
15
15
</div >
16
16
</template >
17
17
18
18
<script >
19
+ import { computed } from ' vue'
19
20
import { useStore } from ' vuex'
20
21
21
22
export default {
@@ -36,8 +37,17 @@ export default {
36
37
store .dispatch (' posts/fetchPostData' , post .id )
37
38
}
38
39
40
+ const post = computed (() => {
41
+ return store .state .posts .post
42
+ })
43
+
44
+ const postTitle = computed (() => {
45
+ return store .getters [' posts/postTitle' ]
46
+ })
47
+
39
48
return {
40
- store,
49
+ postTitle,
50
+ post,
41
51
fetchPost,
42
52
posts,
43
53
}
You can’t perform that action at this time.
0 commit comments