VueJS: How to scroll v-list-title

故事扮演 提交于 2020-06-16 05:21:06

问题


While making list screen with v-list.
I stuck scrolling v-list-title items.

I'm using VueJS and vuetifyjs.

My code snip is at below.

https://codepen.io/badsaarow/pen/aaRaxe?editors=1010

My aim is that toolbar area is fixed, and only v-list-titles are scrollable.

<div id="app">
  <v-app id="inspire">
    <v-container fluid grid-list-lg>
      <v-layout row wrap>
        <v-flex xs12 sm12 md6>
 <v-card>

                <v-toolbar color="light-blue" light extended>
                  <v-btn
                    fab
                    small
                    color="cyan accent-2"
                    bottom
                    right
                    absolute
                    @click="dialog = !dialog"
                  >
                    <v-icon>add</v-icon>
                  </v-btn>
                  <v-toolbar-title slot="extension" class="white--text">user list</v-toolbar-title>
                  <v-spacer></v-spacer>
                </v-toolbar>


                <v-list two-line> 
                  <v-list-tile
                    v-for="user in users"
                    avatar
                    @click=""
                  >
                    <v-list-tile-avatar>
                      <v-icon :class="iconClass">face</v-icon>
                    </v-list-tile-avatar>

                    <v-list-tile-content>
                      <v-list-tile-title>{{ user.lastName }}{{ user.firstName }}</v-list-tile-title>
                      <v-list-tile-sub-title>{{ user.name }}</v-list-tile-sub-title>
                    </v-list-tile-content>

                    <v-list-tile-action>
                      <v-btn icon ripple>
                        <v-icon color="grey lighten-1">info</v-icon>
                      </v-btn>
                    </v-list-tile-action>
                  </v-list-tile>
                </v-list>
              </v-card>
        </v-flex>
      </v-layout>
    </v-container>
  </v-app>
</div>

回答1:


Try to add following CSS to make v-list-titles scrollable.

.v-list {
  height: 300px;
  overflow-y: auto;
}

We need to specify a fixed height for our DOM object, and once we set the overflow-y attribute as auto. A scroll bar will show up once content has bigger length than parent.

Here is the modified version, have a try.




回答2:


Just add the fixed prop to v-toolbar, as so:

<v-toolbar color="light-blue" light extended fixed>

See here for updated pen



来源:https://stackoverflow.com/questions/52382449/vuejs-how-to-scroll-v-list-title

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!