vue-devtools始终与nuxt.js禁用

jos*_*son 3 vue.js nuxt.js vue-devtools

我正在使用nuxt.js v2.3.0创建一个新项目。当我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) {

    }
  }
};
Run Code Online (Sandbox Code Playgroud)

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

jos*_*son 5

我必须在nuxt.config.js中添加以下内容:

vue: {
  config: {
    productionTip: false,
    devtools: true
  }
}
Run Code Online (Sandbox Code Playgroud)

现在显示devtools

  • 当它起作用时,您正在运行什么版本?我使用的是最新的v2.4.5,没有运气。https://nuxtjs.org/api/configuration-build#devtools表示我们应该能够在构建配置中将devtools设置为true,但这对我也不起作用(也不能与此结合使用)。 (4认同)

Jan*_*ees 5

总: 博士:

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

完整故事

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

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

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

运行后nuxt generate --devtools,然后使用 为应用程序提供服务nuxt start,我终于可以访问开发工具了。
现在,即使在运行时nuxt dev它们仍然可以访问。而且我vue.config.devtoolsnuxt.config.js. 诡异的。但也许这对某人有帮助。

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