2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-17 13:30:35 +03:00

docs(example): optimized selected el

This commit is contained in:
mengxiong10
2019-11-12 12:14:25 +08:00
parent 4626de2593
commit 9ea53a5923
3 changed files with 54 additions and 18 deletions
+17
View File
@@ -113,8 +113,24 @@ const titleAndDescMap = transformMd(en);
const App = {
name: 'App',
data() {
return {
currentId: this.getCurrentId(),
};
},
mounted() {
hljs.initHighlighting();
window.onhashchange = () => {
this.currentId = this.getCurrentId();
};
if (this.currentId) {
document.getElementById(this.currentId).scrollIntoView();
}
},
methods: {
getCurrentId() {
return location.hash.slice(1);
},
},
render(h) {
const menus = components.map(item => {
@@ -130,6 +146,7 @@ const App = {
const props = {
id,
code,
active: id === this.currentId,
...titleAndDescMap[id],
};
return <Card {...{ props }}>{h(component)}</Card>;