router.beforeEach 在main.js一加上就报错是为什么?

一打开beforeEach的注释就报错是为什么?

import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui';
import VueLazyload from 'vue-lazyload'
import Vuex from './vuex/store'
import './global.css'
import 'element-ui/lib/theme-chalk/index.css';
import {createRouter} from "./router";
import './assets/iconfont/iconfont.css'
import 'babel-polyfill'
import  VueQuillEditor from 'vue-quill-editor'
// require styles 引入样式
import {get,post,postUp,postLogin,patch,del,postdel,put,posttree,posttree1} from './utils/https'
import {setCookie,delCookie,getCookie} from './utils/cookie'
import md5 from 'js-md5';
Vue.prototype.$md5 = md5;
Vue.prototype.$get = get
Vue.prototype.$post = post
Vue.prototype.$del = del
Vue.prototype.$put = put
Vue.prototype.$postLogin = postLogin
Vue.prototype.$postUp = postUp
Vue.prototype.$setCookie = setCookie
Vue.prototype.$posttree = posttree
Vue.prototype.$posttree1 = posttree1
Vue.prototype.$postdel = postdel


import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)
Vue.use(VueLazyload)


const router = createRouter()

// router.beforeEach((to,from,next)=>{
//   if(to.meta.requireAuth){
//     if(getCookie('session')){
//       next()
//     }else {
//       next({
//         path:'/',
//         query:{redirect: to.fullPath}
//       })
//     }
//   }else {
//     next()
//   }
// }

Vue.use(Vuex)
Vue.config.productionTip = false


Vue.use(ElementUI);
Vue.use(VueLazyload, {
  loading: './assets/mo.png',//图片加载的路径
  listenEvents:['scroll','wheel','mousewheel','resize','animationend','transitionend','touchmove'], 
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})


clipboard.png

阅读 3.2k
2 个回答

你少了个后括弧)......

少了个右括号。。。。。。。

router.beforeEach((from,to,next)=>{

})

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题