使用 vuetify、flexbox 和列表进行自动换行
Word Wrapping with vuetify, flexbox, and lists
我有一个带有 v-list 的 flexbox。我的问题是 v-list 中有一些文本没有换行。我看到以下内容:
看起来包含列表的部分在宽度上无限增长,这就是它不会换行的原因。
我在 https://codepen.io/james-hudson3010/pen/GRobYRo 有一个 CodePen,它演示了这个问题。
JAVASCRIPT:
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.'
}
]
}),
})
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>
需要更改哪些内容才能使文本正确换行?
添加内置 text-wrap
class:
<v-list-item-subtitle class="text-wrap" v-text="item.comment"></v-list-item-subtitle>
我有一个带有 v-list 的 flexbox。我的问题是 v-list 中有一些文本没有换行。我看到以下内容:
看起来包含列表的部分在宽度上无限增长,这就是它不会换行的原因。
我在 https://codepen.io/james-hudson3010/pen/GRobYRo 有一个 CodePen,它演示了这个问题。
JAVASCRIPT:
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.'
}
]
}),
})
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>
需要更改哪些内容才能使文本正确换行?
添加内置 text-wrap
class:
<v-list-item-subtitle class="text-wrap" v-text="item.comment"></v-list-item-subtitle>