无法删除Vuetify导航抽屉上的滚动条

qni6mghb  于 2023-05-07  发布在  Vue.js
关注(0)|答案(4)|浏览(169)

我把导航面板移到了一个V型导航抽屉里。我想删除滚动条,因为有我想始终可见的内容。我已经尝试了各种技巧,但滚动条仍然存在。我怎么能隐藏或摆脱它?

<v-navigation-drawer
  v-model="mainNavDrawer"
  fixed
  app
  clipped
  enable-resize-watcher
  width="475"
  class="pa-0"
  mobile-break-point="1600"
  ><v-layout class="primary ma-0 pa-2 pt-1 d-xl-none">
    <v-toolbar-title class="pa-1 white--text font-weight-bold"
      >Knight Shop Invoice EasyPay</v-toolbar-title
    >
    <v-spacer></v-spacer>
    <v-btn
      x-small
      class="mt-2 pa-3"
      color="primary lighten-5"
      dark
      outlined
      @click.stop="mainNavDrawer = !mainNavDrawer"
    >
      <v-icon dark left> mdi-arrow-left </v-icon>Close
    </v-btn></v-layout
  >
  <v-container fluid class="py-0">
    <v-row>
      <v-col class="px-0 py-0" sm="12">
        <v-container class="pt-0">
          <v-row>
            <v-col sm="12" class="px-2">
              <TogglePOType />
            </v-col>
          </v-row>
          <transition name="slide-fade">
            <v-row v-show="this.selectedInvoiceStatus === 'needapproval'">
              <v-col sm="12" class="py-0">
                <RegionGraph :height="200" />
              </v-col> </v-row
          ></transition>
          <v-row>
            <v-col sm="12" class="pa-0 pt-2">
              <SelectVendors />
            </v-col>
          </v-row>
        </v-container>
      </v-col>
    </v-row>
  </v-container>
</v-navigation-drawer>

……

<style scoped>
.v-navigation-drawer__content {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}
</style>

我试过使用overflow:隐藏到导航抽屉和下面的每个元素,但仍然没有喜悦。

7eumitmz

7eumitmz1#

对我有用的正确的类声明是

<style scoped>
v::deep .v-navigation-drawer__content {
 overflow: hidden
}

</style>

Above is all I did
v::deep allows class to reach child components even with scoped property on

如果不想使用v::deep,请尝试删除style标记中的scoped属性

<style> <--- note without the scoped property
the scoped property prevent any class delcarations from reaching other components
In this case, since vuetify components are considered as separate component
scope tag will prevent your class delcaration take effect

目前使用vuetify 2.6.1
请注意,上面的工作在删除滚动条,但也禁止用户滚动鼠标滚轮,所以我采取了下面的方法。

<style scoped>
::v-deep ::-webkit-scrollbar {
  width: 0
  background: transparent
}

Doing this allows hiding of scroll bar while still enables scrolling
</style>

请参阅此处了解详细说明。Hide scroll bar, but while still being able to scroll

kmbjn2e3

kmbjn2e32#

试试这个!这是我的工作。

.v-navigation-drawer__content::-webkit-scrollbar-track{
  -webkit-box-shadow: inset 0 0 6px #5d5d5d;
  background-color: #5d5d5d;
}
.v-navigation-drawer__content::-webkit-scrollbar{
  width: 0px;
}
.v-navigation-drawer__content::-webkit-scrollbar-thumb{
  -webkit-box-shadow: inset 0 0 6px #424242;
  background-color: #424242;
}

让我知道如果你能做到!:)

6tdlim6h

6tdlim6h3#

不要在样式标签中使用'scoped'。

zlwx9yxi

zlwx9yxi4#

添加额外的类,您将能够删除

<v-navigation-drawer class="hide-scrollbar">
</v-navigation-drawer>

.hide-scrollbar {
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;

  /* Firefox */
  &::-webkit-scrollbar {
    display: none;
  }
}

相关问题