我正在使用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) {
}
}
};
如果我以生产模式运行,那么我可以理解,但我不是。我希望vue-devtools能够正常运行。
答案 0 :(得分:3)
在nuxt.config.js中
export default {
mode: 'universal',
devtools: true,
...
}
希望有人能在这里停下来。
答案 1 :(得分:2)
正如@joshua jackson所说的那样,对我有用,而devtools: true
却没有。
版本:
Nuxt.js v2.10.0
Vue v2.6.10
vue: {
config: {
productionTip: false,
devtools: true
}
}
答案 2 :(得分:1)
我必须在nuxt.config.js中添加以下内容:
vue: {
config: {
productionTip: false,
devtools: true
}
}
现在显示devtools
答案 3 :(得分:1)
vue.config.devtools = true
中的nuxt.config.js
对我不起作用。nuxt generate --devtools
,然后运行nuxt start
,然后在浏览器中打开了该网站。这样做可以使用Vue-Devtools。nuxt dev
并且在我的vue.config.devtools
中未设置nuxt.config.js
标志时,我现在仍然可以使用Vue-Devtools 因此,像在accepted answer中一样在devtools
中启用vue.config
标志对我也不起作用。
我首先按照here的说明尝试强制使用Vue-Devtools。如链接中所述,添加一个插件来设置window
属性。但是没有运气。
挖掘Nuxt代码时,我注意到--devtools
命令的generate
标志,并想了解Vue-Devtools是否可以与Nuxt一起使用。
运行nuxt generate --devtools
,然后用nuxt start
服务应用程序之后,我终于可以访问devtools。
现在,即使运行nuxt dev
,它们仍然可以访问。而且我的vue.config.devtools
中根本没有设置nuxt.config.js
。奇怪的。但这也许可以帮助某人。
更多上下文:我正在spa
模式下运行Nuxt,目标为static
,因为我在后端没有节点服务器,只想构建一个SPA。
答案 4 :(得分:0)
我一直在努力工作,并尝试了此处编写的所有步骤。
我的问题是我必须在指定端口上运行服务器。
-R
将此内容添加到server: {
port: process.env.PORT || 5000,
host: '0.0.0.0'
},
即可解决问题。