Item.vue 1.3 KB

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