naive-ui/demo/utils/ComponentDocumentation.vue

38 lines
784 B
Vue
Raw Normal View History

2019-09-21 17:03:37 +08:00
<template>
2019-10-14 17:49:23 +08:00
<div class="n-documentation">
2019-09-21 17:03:37 +08:00
<slot />
</div>
</template>
2019-10-14 17:49:23 +08:00
2020-02-01 16:45:37 +08:00
<script>
export default {
inject: {
NDocRoot: {
default: null
}
},
mounted () {
const paramsRegex = /\/([^/]+)\/([^/]+)\/([^/]+)/
if (this.NDocRoot.memorizedPath) {
const memorizedPath = this.NDocRoot.memorizedPath
const currentPath = this.$route.path
const memorizedDemoName = (paramsRegex.exec(memorizedPath) || [])[3]
const currentDemoName = (paramsRegex.exec(currentPath) || [])[3]
if (
memorizedDemoName &&
currentDemoName &&
memorizedDemoName !== currentDemoName
) {
this.NDocRoot.resetScrollPosition()
}
}
2020-02-01 16:45:37 +08:00
}
}
</script>
2019-10-14 17:49:23 +08:00
<style>
.n-documentation {
2020-01-27 21:14:34 +08:00
padding: 24px 24px 24px 56px;
2019-10-14 17:49:23 +08:00
}
</style>