使用 vuetify、flexbox 和列表进行自动换行

Jam*_*son 1 css word-wrap flexbox vue.js vuetify.js

我有一个带有 v-list 的 flexbox。我的问题是 v-list 中有一些未换行的文本。我看到以下内容:

在此处输入图片说明

似乎包含列表的部分在宽度上无限增长,这就是它不会换行的原因。

我在https://codepen.io/james-hudson3010/pen/GRobYRo有一个 CodePen,它演示了这个问题。

爪哇脚本:

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  props: {
    source: String,
  },

  data: () => ({
    selectedItem: null,
    flattened: [
      {
        'name': 'item 3 title content',
        'comment': 'this is a really long comment to see what will happen with the text. I would like this text to wrap, but I am pretty sure it will not do that yet. This is just a test to see what is going to happen as it grows really long. Will this text ever wrap.'
      }      
    ]
  }),
})
Run Code Online (Sandbox Code Playgroud)

HTML:

<div id="app">
  <v-app id="inspire">
    <div class="d-flex flex-row align-stretch" style="width: 100%;">
      <div style="background-color: red; width: 500px">
        <v-btn class="ma-4">A button</b-btn>
      </div>
      <v-card style="background-color: lightgreen" style="width: 100%">
        <v-list dense flat color="transparent" >
          <v-list-item-group v-model="selectedItem">
            <v-list-item v-for="item in flattened" :key="item.id">
                <v-list-item-content>
                  <v-list-item-title v-text="item.name"></v-list-item-title>
                  <v-list-item-subtitle style="overflow-wrap: break-word;" v-text="item.comment"></v-list-item-subtitle>
                </v-list-item-content>
            </v-list-item>
        </v-list-item-group>         
       </v-list>     
    </v-card>
  </v-app>
</div>
Run Code Online (Sandbox Code Playgroud)

要使文本正确换行,需要进行哪些更改?

Igo*_*aru 11

添加内置text-wrap类:

 <v-list-item-subtitle class="text-wrap" v-text="item.comment"></v-list-item-subtitle>
Run Code Online (Sandbox Code Playgroud)