[Vuejs]-Where to set devtools = true for vue.js devtools?

0👍

Okay, I found the answer myself:
This is what the code of main.js looks like with devtools=true:

import VueResource from 'vue-resource'
import VueRouter from 'vue-router'
import Routes from './routes'
import App from './App.vue'
import Vue from 'vue'
import './style/customColor.scss';

import store from "./store/store";
import { USER_ROLECHECK } from './store/actions/user'
import { REQ_ADMIN_ROLE } from "./utility/namespaces";

Vue.use(VueResource);
Vue.use(VueRouter);
//HERE IT IS=============================================================
Vue.config.devtools = true; //this line should be removed in the actual live 
build!
//HERE IT IS==================================================

const router = new VueRouter({
    routes: Routes,
    mode: 'history'
})

router.beforeEach((to, from, next) => {
  if(to.meta.reqAuth){
    if(store.getters.isAuthenticated){
      if(to.meta.reqAdmin){
        store.dispatch(USER_ROLECHECK, REQ_ADMIN_ROLE).then(() =>{
          next();
        }).catch(() =>{
          next({path: '/'})
        })
      }else{
        next();
      }
    }else{
      next({path: '/login'});
    }
  }else{
    next();
  }
})

new Vue({
  el: '#app',
   router,
   store,
  render: h => h(App),
})

Leave a comment