@nuxtjs/vuetify 没有应用样式
@nuxtjs/vuetify no style applied
我在 Nuxt 项目中使用 vuetify 时遇到问题,我按照文档说你只需要将 @nuxtjs/vuetify
依赖项安装到你的项目并在 buildModules
部分添加一行您的 nuxt.config.js
文件。这些组件工作正常,但我没有看到任何 css 样式,怎么了?
这是我的 nuxt.config.js 文件
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'mounir-ssr-diabete',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
['@nuxtjs/vuetify', {}],
],
router: {},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
[
'@nuxtjs/firebase',
{
config: {
apiKey: 'AIzaSyD_wgrl3S3RjpgwaEP2bDLpLDnIQz2C2Vc',
authDomain: 'mounir-ssr.firebaseapp.com',
projectId: 'mounir-ssr',
storageBucket: 'mounir-ssr.appspot.com',
messagingSenderId: '26338888590',
appId: '1:26338888590:web:be1893a374f3abc10cb2df',
measurementId: 'G-Y7YHDQDLM8',
},
services: {
auth: {
persistence: 'local', // default
initialize: {
onAuthStateChangedAction: 'onAuthStateChangedAction',
subscribeManually: false,
},
ssr: false,
},
},
},
],
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
}
您应该在 nuxt.config.js
文件中与 axios
和 build
一起添加 vuetify
主题信息。像这样..
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
"@nuxtjs/eslint-module",
"@nuxtjs/vuetify",
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
"@nuxtjs/axios",
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {},
vuetify: {
customVariables: ["~/assets/variables.scss"],
theme: {
light: true,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3,
},
},
},
},
有什么不明白的可以问我
我遇到了同样的问题。在我的例子中,在模板代码中使用 v-app
解决了它(例如,仅使用 v-banner
不包含 Vuetify 样式,但是在其周围添加 v-app
时,样式神奇地出现了) .如果您想覆盖 built-in Vuetify 样式,上述 Nuxt 配置文件的答案可能很有用,我也是这种情况(例如,来自 [=10 的 v-application
样式=]需要调整)。
我在 Nuxt 项目中使用 vuetify 时遇到问题,我按照文档说你只需要将 @nuxtjs/vuetify
依赖项安装到你的项目并在 buildModules
部分添加一行您的 nuxt.config.js
文件。这些组件工作正常,但我没有看到任何 css 样式,怎么了?
这是我的 nuxt.config.js 文件
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'mounir-ssr-diabete',
htmlAttrs: {
lang: 'en',
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
['@nuxtjs/vuetify', {}],
],
router: {},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
[
'@nuxtjs/firebase',
{
config: {
apiKey: 'AIzaSyD_wgrl3S3RjpgwaEP2bDLpLDnIQz2C2Vc',
authDomain: 'mounir-ssr.firebaseapp.com',
projectId: 'mounir-ssr',
storageBucket: 'mounir-ssr.appspot.com',
messagingSenderId: '26338888590',
appId: '1:26338888590:web:be1893a374f3abc10cb2df',
measurementId: 'G-Y7YHDQDLM8',
},
services: {
auth: {
persistence: 'local', // default
initialize: {
onAuthStateChangedAction: 'onAuthStateChangedAction',
subscribeManually: false,
},
ssr: false,
},
},
},
],
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
}
您应该在 nuxt.config.js
文件中与 axios
和 build
一起添加 vuetify
主题信息。像这样..
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
"@nuxtjs/eslint-module",
"@nuxtjs/vuetify",
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
"@nuxtjs/axios",
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {},
vuetify: {
customVariables: ["~/assets/variables.scss"],
theme: {
light: true,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3,
},
},
},
},
有什么不明白的可以问我
我遇到了同样的问题。在我的例子中,在模板代码中使用 v-app
解决了它(例如,仅使用 v-banner
不包含 Vuetify 样式,但是在其周围添加 v-app
时,样式神奇地出现了) .如果您想覆盖 built-in Vuetify 样式,上述 Nuxt 配置文件的答案可能很有用,我也是这种情况(例如,来自 [=10 的 v-application
样式=]需要调整)。