EdToc.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <section ref="scrollabletoc">
  3. <ul>
  4. <li
  5. v-for="item in toc"
  6. :key="item.uuid"
  7. >
  8. <TocItem
  9. :item="item"
  10. :level="1"
  11. :editionid="$route.params.id"
  12. :loadedtextsuuids="loadedtextsuuids"
  13. @onClickTocItem="onClickTocItem"
  14. @onScrollToRef="onScrollToRef"
  15. />
  16. </li>
  17. </ul>
  18. </section>
  19. </template>
  20. <script>
  21. import TocItem from './TocItem'
  22. export default {
  23. name: 'EdToc',
  24. components: {
  25. TocItem
  26. },
  27. props: {
  28. toc: Array,
  29. loadedtextsuuids: Array
  30. },
  31. // watch: {
  32. // reftoscrollto: function (newref, oldref) {
  33. // console.log('TOC reftoscrollto watcher', oldref, newref)
  34. // this.scrollToRef()
  35. // }
  36. // },
  37. methods: {
  38. onScrollToRef (uuid) {
  39. // console.log('TOC scrollToRef', uuid, this.$refs)
  40. this.$scrollTo(`a[uuid="${uuid}"]`, 500, {
  41. container: this.$refs.scrollabletoc
  42. })
  43. },
  44. onClickTocItem (uuid) {
  45. this.$emit('onClickTocItem', uuid)
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. </style>