docs_vue2/components/OneToc.vue

31 lines
452 B
Vue
Raw Normal View History

2021-10-25 20:19:04 +08:00
<template>
<nav class="one-toc">
<veui-anchor
2021-10-28 17:03:43 +08:00
ui="s"
2021-10-25 20:19:04 +08:00
sticky
2021-10-28 19:33:38 +08:00
target-offset="120px"
sticky-offset="20px"
2021-10-28 17:03:43 +08:00
:items="flattenItems"
2021-10-25 20:19:04 +08:00
/>
</nav>
</template>
<script>
import { Anchor } from 'veui'
export default {
name: 'one-toc',
components: {
'veui-anchor': Anchor
},
props: {
items: Array
},
computed: {
flattenItems () {
return this.items.flatMap(({ children }) => children || [])
}
2021-10-25 20:19:04 +08:00
}
}
</script>