vue-devtools 总是被 nuxt.js 禁用

新手上路,请多包涵

我正在使用 nuxt.js v2.3.0 创建一个新项目。当我在我的 IDE 控制台中运行 npm run dev 时,一切都可以正确编译,但是当我转到该页面时,出现以下错误: Nuxt.js + Vue.js is detected on this page. Devtools inspection is not available because it's in production mode or explicitly disabled by the author.

这是我的 nuxt.config.js 文件:

 const pkg = require('./package');

module.exports = {
  mode: 'spa',

  dev: true,
  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    bodyAttrs: {
      class: 'h-100'
    },
    htmlAttrs: {
      class: 'h-100'
    }
  },

  /*
  ** Global CSS
  */
  css: [
    '@/assets/app.css'
  ],

  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '~/plugins/vue-notifications',
    '~/plugins/vue2-sidebar'
  ],

  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://github.com/nuxt-community/axios-module#usage
    '@nuxtjs/axios',
    // Doc: https://bootstrap-vue.js.org/docs/
    'bootstrap-vue/nuxt',
    // Doc: https://auth.nuxtjs.org/getting-starterd/setup
    '@nuxtjs/auth',
    '@nuxtjs/toast',
    '@nuxtjs/font-awesome'
  ],
  /*
  ** Axios module configuration
  */
  axios: {
    baseURL: 'http://users:8000'
  },

  /*
  ** Auth module configuration
  */
  auth: {
    strategies: {
      password_grant: {
        _scheme: 'local',
        endpoints: {
          login: {
            url: '/oauth/token',
            method: 'post',
            propertyName: 'access_token'
          },
          logout: 'api/logout',
          user: {
            url: 'api/user',
            method: 'get',
            propertyName: false
          },
        },
        tokenRequired: true,
        tokenType: 'Bearer'
      }
    },
    redirect: {
      login: "/account/login",
      logout: "/",
      callback: "/account/login",
      user: "/"
    },
  },

  /*
  ** Toast configuration
  */
  toast: {
    position: 'top-right',
    duration: 2000
  },

  loading: {
    name: 'chasing-dots',
    color: '#ff5638',
    background: 'white',
    height: '4px'
  },

  /*
  ** Router configuration
  */
  router: {
    middleware: ['auth']
  },

  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {

    }
  }
};

如果我在生产模式下运行,那么我可以理解,但我不是。我希望 vue-devtools 能正常运行。

原文由 joshua jackson 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.5k
2 个回答

我必须将以下内容添加到 nuxt.config.js:

 vue: {
  config: {
    productionTip: false,
    devtools: true
  }
}

现在 devtools 出现了

原文由 joshua jackson 发布,翻译遵循 CC BY-SA 4.0 许可协议

长:博士:

  • vue.config.devtools = true 在我的 nuxt.config.js 对我不起作用。
  • 我跑了 nuxt generate --devtools ,然后 nuxt start 并在我的浏览器中打开了网站。这样做我可以使用 Vue-Devtools。
  • 之后我仍然可以使用 Vue-Devtools,即使在运行 nuxt dev 并且没有 vue.config.devtools 标志设置在我的 nuxt.config.js

全文

因此,在 vue.config 中启用 devtools 标志,如在 接受的答案 中一样,对我也不起作用。

我首先尝试按照 此处 所述强制使用 Vue-Devtools。添加插件以设置 window 属性,如链接中所述。但没有运气。

在挖掘 Nuxt 代码时,我注意到了 --devtools generate 命令的标志,并想看看 Vue-Devtools 是否可以与 Nuxt 一起工作。

运行 nuxt generate --devtools ,然后使用 nuxt start 服务应用程序后,我终于可以访问开发工具了。

现在,即使运行 nuxt dev 它们仍然可以访问。而且我根本没有 vue.config.devtools 设置 nuxt.config.js 。诡异的。但也许这对某人有帮助。

更多上下文:我在 spa 模式下运行 Nuxt,目标 static 因为我在后端没有节点服务器,只想构建一个 SPA。

原文由 Jan-Luca Klees 发布,翻译遵循 CC BY-SA 4.0 许可协议

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