最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How correctly add a scrollable effect to the <v-bottom-sheet> component of the Vuetify framework? - S

programmeradmin1浏览0评论

In my Vue.js application I use v-bottom-sheet ponent of Vuetify (2.1.12) framework. As you can see from my code the v-card is inside the v-bottom-sheet. According to the documentation v-bottom-sheet has scrollable parameter. For some reason, it doesn't work. Where I did a mistake?

I also tried to add a scrollable effect to v-card-text by CSS. I created information-window-v-card-text CSS class for that task. It adds a scrollable effect but the height of the element goes beyond the lower border of the screen. You can see that from the below picture:

InformationWindow.vue:

<template>
  <v-bottom-sheet
    v-model="sheet"
    inset
    max-width="50%"
    hide-overlay
    no-click-animation
    scrollable
    persistent
    dark>
    <v-sheet
      class="information-window-v-sheet">
      <v-card
        v-if="sheet"
        class="information-window-v-card">
        <v-card-title>New York</v-card-title>
        <v-card-subtitle>11201</v-card-subtitle>
        <v-divider></v-divider>
        <v-card-text>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
        </v-card-text>
      </v-card>
    </v-sheet>
  </v-bottom-sheet>
</template>

<script>
export default {
  name: 'InformationWindow',
  data: () => ({
    sheet: true
  })
}
</script>

<style scoped>
  .information-window-v-sheet{
    height: 50vh !important;
    border-bottom-left-radius: unset !important;
    border-bottom-right-radius: unset !important;
    background-color: rgba(0,0,0,0.5) !important;
  }
  .information-window-v-card{
    height: 100% !important;
    background-color: unset !important;
  }
  .information-window-v-card-text{
    height: 100%;
    overflow-y: scroll;
  }
</style>

In my Vue.js application I use v-bottom-sheet ponent of Vuetify (2.1.12) framework. As you can see from my code the v-card is inside the v-bottom-sheet. According to the documentation v-bottom-sheet has scrollable parameter. For some reason, it doesn't work. Where I did a mistake?

I also tried to add a scrollable effect to v-card-text by CSS. I created information-window-v-card-text CSS class for that task. It adds a scrollable effect but the height of the element goes beyond the lower border of the screen. You can see that from the below picture:

InformationWindow.vue:

<template>
  <v-bottom-sheet
    v-model="sheet"
    inset
    max-width="50%"
    hide-overlay
    no-click-animation
    scrollable
    persistent
    dark>
    <v-sheet
      class="information-window-v-sheet">
      <v-card
        v-if="sheet"
        class="information-window-v-card">
        <v-card-title>New York</v-card-title>
        <v-card-subtitle>11201</v-card-subtitle>
        <v-divider></v-divider>
        <v-card-text>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
          <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
          <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
        </v-card-text>
      </v-card>
    </v-sheet>
  </v-bottom-sheet>
</template>

<script>
export default {
  name: 'InformationWindow',
  data: () => ({
    sheet: true
  })
}
</script>

<style scoped>
  .information-window-v-sheet{
    height: 50vh !important;
    border-bottom-left-radius: unset !important;
    border-bottom-right-radius: unset !important;
    background-color: rgba(0,0,0,0.5) !important;
  }
  .information-window-v-card{
    height: 100% !important;
    background-color: unset !important;
  }
  .information-window-v-card-text{
    height: 100%;
    overflow-y: scroll;
  }
</style>
Share Improve this question edited Dec 27, 2019 at 6:41 Nurzhan Nogerbek asked Dec 27, 2019 at 6:12 Nurzhan NogerbekNurzhan Nogerbek 5,24620 gold badges98 silver badges201 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Well, finally I solved my problem. I removed the <v-sheet> tag. Without this tag scrollable parameter of the v-bottom-sheet ponent works.

In alternative you could use height prop in v-card-text ponent, inside v-card

<v-bottom-sheet
    v-model="sheet"
    inset
    max-width="50%"
    hide-overlay
    no-click-animation
    scrollable
    persistent
    dark>
    <v-card
      v-if="sheet"
      class="information-window-v-card">
      <v-card-title>New York</v-card-title>
      <v-card-subtitle>11201</v-card-subtitle>
      
      <v-divider />

      <v-card-text height="70%">
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
        <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
        <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
        <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
        <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum es from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", es from a line in section 1.10.32.</p>
        <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, acpanied by English versions from the 1914 translation by H. Rackham.</p>
      </v-card-text>
    </v-card>
  </v-bottom-sheet>

That worked for me

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论