Skip to content

Instantly share code, notes, and snippets.

@simonjcarr
Created August 14, 2020 22:47
Show Gist options
  • Select an option

  • Save simonjcarr/ef0dcafd7b9b2f2fe97131bc8c81d9dd to your computer and use it in GitHub Desktop.

Select an option

Save simonjcarr/ef0dcafd7b9b2f2fe97131bc8c81d9dd to your computer and use it in GitHub Desktop.
Post.vue with the composition API
<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