Item.vue 1.2 KB

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