admin管理员组文章数量:1393091
I have a vuetify snackbar and I am displaying a message on it. I want the snackbar to adjust itself dynamically, if I type in a long message. At the moment the snackbar is facilitating just 2 lines and then it does not go to the third line and instead if the message is too long, it exceeds the size of the snackbar and hence some of the message is not visible anymore. How can I make it grow dynamically such that it facilitates very long messages as well. Following is my code:
<template>
<div>
<v-snackbar
v-model="snackbar"
:bottom="y === 'bottom'"
:left="x === 'left'"
:multi-line="mode === 'multi-line'"
:right="x === 'center'"
:timeout="timeout"
:top="y === 'top'"
:vertical="mode === 'vertical'"
:color="'success'"
>
<div>{{ text }}</div>
<v-btn
color="white"
flat
@click="snackbar = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</template>
<script>
export default {
data: () => ({
snackbar: true,
y: 'top',
x: 'right',
mode: '',
timeout: 6000,
text: 'Yayy! Benutzer erfolgreich angelegt',
}),
};
</script>
I have a vuetify snackbar and I am displaying a message on it. I want the snackbar to adjust itself dynamically, if I type in a long message. At the moment the snackbar is facilitating just 2 lines and then it does not go to the third line and instead if the message is too long, it exceeds the size of the snackbar and hence some of the message is not visible anymore. How can I make it grow dynamically such that it facilitates very long messages as well. Following is my code:
<template>
<div>
<v-snackbar
v-model="snackbar"
:bottom="y === 'bottom'"
:left="x === 'left'"
:multi-line="mode === 'multi-line'"
:right="x === 'center'"
:timeout="timeout"
:top="y === 'top'"
:vertical="mode === 'vertical'"
:color="'success'"
>
<div>{{ text }}</div>
<v-btn
color="white"
flat
@click="snackbar = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</template>
<script>
export default {
data: () => ({
snackbar: true,
y: 'top',
x: 'right',
mode: '',
timeout: 6000,
text: 'Yayy! Benutzer erfolgreich angelegt',
}),
};
</script>
Share
Improve this question
asked Mar 11, 2019 at 9:58
SalmanSalman
4311 gold badge8 silver badges27 bronze badges
2 Answers
Reset to default 3You can even grow your Snackbar's width according to the content, by default there's a fixed width. You can overwrite by selecting wrapper class of v-snackbar
<style scoped>
.v-snack__wrapper {
max-width: none;
}
</style>
This will grow your snackbar in width. Working example:https://codepen.io/saurabhtalreja/pen/yLJBvZm
If in case you're not able to change width using this, append ::v-deep in front of class, this gives more specificity.
Use the auto-height
property:
<v-snackbar v-model="snackbar"
:bottom="y === 'bottom'" :left="x === 'left'"
:multi-line="mode === 'multi-line'" :right="x === 'center'"
:timeout="timeout" :top="y === 'top'" :vertical="mode === 'vertical'"
:color="'success'" :auto-height="true">
[ https://vuetifyjs./en/ponents/snackbars#api ]
[ https://jsfiddle/stdob__/bdz90kap/ ]
本文标签: javascriptHow to make the vuetify snackbar grow dynamicallyStack Overflow
版权声明:本文标题:javascript - How to make the vuetify snackbar grow dynamically? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744677325a2619189.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论