Commit 95ac7390 authored by 徐一鸣's avatar 徐一鸣

开发文档页面优化

parent 84e703ab
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<div <div
class="part_content doc_content apaas_scroll" class="part_content doc_content apaas_scroll"
v-html="content" v-html="content"
ref="docContent"
></div> ></div>
</div> </div>
<div class="part nav_part"> <div class="part nav_part">
...@@ -38,9 +39,8 @@ ...@@ -38,9 +39,8 @@
item.id === curNav ? ' current' : '', item.id === curNav ? ' current' : '',
]" ]"
:key="index" :key="index"
@click="clickNav(item)"
> >
<a :href="'#' + item.id" v-text="item.title"></a> <a v-text="item.title" @click="clickNav(item)"></a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -151,8 +151,22 @@ export default { ...@@ -151,8 +151,22 @@ export default {
successCallback(richTextContent); successCallback(richTextContent);
}, },
clickNav(item) { clickNav(item) {
let target = document.querySelector(`#${item.id}`);
this.setScroll(target, this.$refs.docContent);
this.curNav = item.id; this.curNav = item.id;
}, },
setScroll(el, parentEl) {
let actualTop = el.offsetTop;
let current = el.offsetParent;
while (current !== null) {
actualTop += current.offsetTop;
current = current.offsetParent;
}
parentEl.scrollTop = actualTop - parentEl.offsetTop;
},
}, },
}; };
</script> </script>
...@@ -248,6 +262,7 @@ export default { ...@@ -248,6 +262,7 @@ export default {
line-height: 30px; line-height: 30px;
color: #58617a; color: #58617a;
text-decoration: none; text-decoration: none;
cursor: pointer;
} }
.nav_content > li.level_1 > a { .nav_content > li.level_1 > a {
color: #242c43; color: #242c43;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment