Skip to content

Commit 88047f6

Browse files
committed
fix to.hash
1 parent 207a000 commit 88047f6

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

docs/dist/index.js

Lines changed: 13 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ Vue.directive('markdown', function (el, binding, vnode) {
6868
for (let i = 0; i < vnode.children.length; i++) {
6969
text += vnode.children[i].text || ''
7070
}
71+
if (el.markdown === text) {
72+
return
73+
}
74+
75+
el.markdown = text
7176

7277
el.innerHTML = marked(text)
7378
let selectorList = el.querySelectorAll('a')

docs/router.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ let examples = [
5454
const router = new VueRouter({
5555
mode: 'hash',
5656
fallback: false,
57-
scrollBehavior() {
58-
return { y: 0 }
57+
scrollBehavior(to, from, savedPosition) {
58+
if (savedPosition) {
59+
return savedPosition
60+
} else if (to.hash) {
61+
return { selector: to.hash }
62+
} else {
63+
return { x: 0, y: 0 }
64+
}
5965
},
6066
routes: [
6167
{

docs/views/Document.vue

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,5 @@ export default {
100100
return rootNode.children
101101
},
102102
},
103-
watch: {
104-
/**
105-
* [$route description]
106-
* @param {[type]} route [description]
107-
* @return {[type]} [description]
108-
*/
109-
$route(route) {
110-
if (route.hash) {
111-
let el = document.querySelector(route.hash)
112-
window.scrollTo(0, el ? el.offsetTop : 0)
113-
} else {
114-
window.scrollTo(0, 0)
115-
}
116-
}
117-
},
118103
}
119104
</script>

0 commit comments

Comments
 (0)