首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在哪里为vue.js devtools设置devtools = true?

在哪里为vue.js devtools设置devtools = true?
EN

Stack Overflow用户
提问于 2020-03-10 18:04:33
回答 1查看 192关注 0票数 0

我的vue应用程序的main.js如下所示:

代码语言:javascript
复制
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);

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),
})

我在生产模式下运行vue。我仍然想使用devtools,但是他们给了我这个错误:

代码语言:javascript
复制
Vue.js is detected on this page.
Devtools inspection is not available because it's in production mode or explicitly disabled by the author. 

我在这里读到https://github.com/vuejs/vue-devtools/issues/190,我需要像这样更改main.js:

代码语言:javascript
复制
You are probably using Vue from CDN, and probably using a production build (dist/vue.min.js). Either replace it with a dev build (dist/vue.js) or add Vue.config.devtools = true to the main js file.

但我不知道在哪里将此条目添加到我的项目/应用程序main.js中:(请帮助!

EN

回答 1

Stack Overflow用户

发布于 2020-03-10 18:28:34

好了,我自己找到了答案:这是使用devtools=true的main.js代码:

代码语言:javascript
复制
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),
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60615311

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档