Vuetify - 设置背景 img

El *_*bre 4 css vue.js vuetify.js

Vuetify中(Vue组件超级集)中,我想在背景中添加图像图案。

\n\n

我试过

\n\n
body {\n    background: url("/images/background.png") no-repeat center center fixed;\n    background-size: cover;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但这不起作用,某些 vuetify 组件取消了这种样式。我想要一种优雅的方式来做到这一点,而不是直接在组件或 html 中插入样式。

\n\n

有人遇到过这个错误吗?我如何解决它?

\n

小智 5

在你的 v-container 上放置一个类

<template>
    <v-container class="hero">
    </v-container>
</template>

<style scoped>
.hero {
  background: url('../assets/yourImage.jpg');
  background-size: cover;
  height: 100vh;
}
</style>
Run Code Online (Sandbox Code Playgroud)