Created
August 14, 2020 22:47
-
-
Save simonjcarr/ef0dcafd7b9b2f2fe97131bc8c81d9dd to your computer and use it in GitHub Desktop.
Post.vue with the composition API
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
| <template> | |
| <div> | |
| <div class="text-4xl font-bold">{{ post.title }}</div> | |
| <div>{{ post.body }}</div> | |
| <div class="italic mt-4"> | |
| Author: <span class="text-red-500">{{ user.name }}</span> | |
| </div> | |
| </div> | |
| </template> | |
| <script> | |
| import usePosts from "@/composables/blog/posts"; | |
| import router from "@/router"; | |
| export default { | |
| setup() { | |
| const { currentRoute } = router; | |
| const { fetchPost, post, user } = usePosts(); | |
| fetchPost(currentRoute.value.params.id); | |
| return { post, user }; | |
| } | |
| }; | |
| </script> | |
| <style></style> | |
| © 2020 GitHub, Inc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment