main.js
1.5 KB
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
45
46
47
48
49
50
51
52
53
import 'babel-polyfill';
// import 'core-js/stable';
// import 'regenerator-runtime/runtime';
import Vue from 'vue'
import App from './App.vue'
import router from '@/router'
import store from '@/store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import VueClipboard from 'vue-clipboard2'
import 'swiper/css/swiper.css' // 同时必须引入css样式文件
import wx from 'weixin-js-sdk';
import VueQuillEditor from 'vue-quill-editor'
import VueLazyload from 'vue-lazyload';
import VueCropper from 'vue-cropper'
Vue.use(VueCropper)
// 使用插件 里边放置了全局组件
import plugin from '@/components'
import axios from '@/api'
// import filte from '@/filter'
import '@/style/index.less'
Vue.use(VueLazyload, {
error: 'dist/error.png',
loading: 'dist/loading.gif'
});
Vue.use(VueQuillEditor)
Vue.use(plugin)
Vue.use(VueClipboard)
Vue.use(wx)
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueAwesomeSwiper)
router.afterEach((to, from, next) => {
window.scrollTo(0, 0);
})
router.beforeEach((to, from, next) => {
if (to.matched.length === 0) { //匹配前往的路由不存在
from.name ? next({
name: from.name
}) : next('/404'); //判断此跳转路由的来源路由是否存在,存在的情况跳转到来源路由,否则跳转到404页面
} else {
next(); //如果匹配到正确跳转
}
});
new Vue({
router,
store,
render: h => h(App) // 这是创建的简写
}).$mount('#app')