forked from bailichen/vue-weixin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (41 loc) · 909 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './router/router'
import store from './vuex/'
import './style/public.scss'
import './config/rem'
import FastClick from 'fastclick'
import App from './app.vue';
if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
Vue.use(VueRouter)
const router = new VueRouter({
routes,
mode: 'history', //路由模式
strict: process.env.NODE_ENV !== 'production',
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return {
x: 0,
y: to.meta.savedPosition || 0
}
}
}
})
router.beforeEach((to, from, next) => {
if (from.meta.keepAlive) {
from.meta.savedPosition = document.body.scrollTop;
}
next()
})
new Vue({
el: '#weixin',
router,
render: h => h(App),
store,
})