naive-ui/demo/utils/ComponentDocumentation.vue

38 lines
793 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 () {
2020-02-27 18:09:23 +08:00
const paramsRegex = /\/([^/]+)\/([^/]+)\/([^/]+)\/([^/]+)/
if (this.NDocRoot.memorizedPath) {
const memorizedPath = this.NDocRoot.memorizedPath
const currentPath = this.$route.path
2020-02-27 18:09:23 +08:00
const memorizedDemoName = (paramsRegex.exec(memorizedPath) || [])[4]
const currentDemoName = (paramsRegex.exec(currentPath) || [])[4]
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-03-05 22:31:20 +08:00
padding: 32px 24px 24px 56px;
2019-10-14 17:49:23 +08:00
}
</style>