如何在Vuetify 3、Vue 3的v导航抽屉中为图像添加渐变?

aurhwmvo  于 2022-12-23  发布在  Vue.js
关注(0)|答案(1)|浏览(127)

我在我的Vue 3应用程序中使用v-navigation-drawer与Vuetify 3:

<template>
    <v-navigation-drawer app :image="backgroundImage">
        ...
    </v-navigation-drawer>
</template>
  
<script>
import backgroundImage from ' @/assets/backgroundImage.jpg'
export default {
    name: 'MyDrawer',
    setup() {
        return { backgroundImage }
    },
}
</script>

我想给这张图像添加一个渐变,类似于

<v-img
src="backgroundImage"
gradient="to top right, rgba(100,115,201,.33), rgba(25,32,72,.7)"
></v-img>

我该怎么做呢?

ruarlubt

ruarlubt1#

//Adding id to navigation drawer 
<v-navigation-drawer 
    id="nav_drawer">
</v-navigation-drawer>

 // In the style tag, assign image and gradient for background
<style>
#nav_drawer{
    background-image: linear-gradient(to bottom, rgba(245, 246, 252, 0.52), rgba(117, 19, 93, 0.73)), url('https://cdn.vuetifyjs.com/images/backgrounds/bg-2.jpg');
    background-size: cover;
    color: white;
}
</style>

相关问题