Item.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <transition name="fade" appear>
  3. <span v-if="!loaded">Loading...</span>
  4. <article v-else class="item">
  5. <header>
  6. <h1>
  7. {{ item.title }}
  8. </h1>
  9. </header>
  10. <section v-html="item.tei" />
  11. </article>
  12. </transition>
  13. </template>
  14. <script>
  15. import { REST } from 'api/rest-axios'
  16. export default {
  17. name: 'Item',
  18. props: {
  19. uuid: {
  20. type: String,
  21. required: true
  22. }
  23. },
  24. data: () => ({
  25. loaded: false,
  26. item: {}
  27. }),
  28. watch: {
  29. '$route' (to, from) {
  30. console.log('item route change')
  31. this.loadItem()
  32. }
  33. },
  34. created () {
  35. console.log('Item created', this.uuid)
  36. this.loadItem()
  37. },
  38. updated () {
  39. console.log('item updated', this.uuid)
  40. },
  41. methods: {
  42. loadItem () {
  43. this.loaded = false
  44. REST.get(`/items/` + this.uuid, {})
  45. .then(({ data }) => {
  46. console.log('item REST: data', data)
  47. this.item = data.content
  48. this.loaded = true
  49. })
  50. .catch((error) => {
  51. console.warn('Issue with item', error)
  52. Promise.reject(error)
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. </style>