如何让 Vuetify snackbar 适合文本?
How to make Vuetify snackbar fit around text?
我正在使用 Vuetify 的 snackbar 组件,似乎有一个固定的最小宽度,因为无论文本多短,它都不会减少 snackbar,只有当文本变得很长时,大小才会改变。是否可以“强制”快餐栏匹配我的文本大小?
我的代码:
<template>
<v-snackbar v-model="show" :color="color" :timeout="timeout" right top >
{{ message }}
<v-icon v-if="color === 'success'" >fas fa-thumbs-up</v-icon>
<v-icon v-else >fas fa-thumbs-down</v-icon>
</v-snackbar>
</template>
<script>
export default {
data () {
return {
timeout: '3000',
show: false,
message: '',
color: ''
}
},
created () {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'snackbar/showMessage') {
this.message = state.snackbar.content
this.color = state.snackbar.color
this.show = true
}
})
}
}
</script>
我在 Whosebug 上找到了类似的东西,但它只适用于高度。
我能够使用此 修复它,所以现在我的代码如下所示:
<template>
<v-snackbar v-model="show" :color="color" :timeout="timeout" right top >
{{ message }}
<v-icon v-if="color === 'success'" >fas fa-thumbs-up</v-icon>
<v-icon v-else >fas fa-thumbs-down</v-icon>
</v-snackbar>
</template>
<script>
export default {
data () {
return {
timeout: '3000',
show: false,
message: '',
color: ''
}
},
created () {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'snackbar/showMessage') {
this.message = state.snackbar.content
this.color = state.snackbar.color
this.show = true
}
})
}
}
</script>
<style scoped>
::v-deep .v-snack__wrapper {
min-width: 0px;
}
</style>
我正在使用 Vuetify 的 snackbar 组件,似乎有一个固定的最小宽度,因为无论文本多短,它都不会减少 snackbar,只有当文本变得很长时,大小才会改变。是否可以“强制”快餐栏匹配我的文本大小?
我的代码:
<template>
<v-snackbar v-model="show" :color="color" :timeout="timeout" right top >
{{ message }}
<v-icon v-if="color === 'success'" >fas fa-thumbs-up</v-icon>
<v-icon v-else >fas fa-thumbs-down</v-icon>
</v-snackbar>
</template>
<script>
export default {
data () {
return {
timeout: '3000',
show: false,
message: '',
color: ''
}
},
created () {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'snackbar/showMessage') {
this.message = state.snackbar.content
this.color = state.snackbar.color
this.show = true
}
})
}
}
</script>
我在 Whosebug
我能够使用此
<template>
<v-snackbar v-model="show" :color="color" :timeout="timeout" right top >
{{ message }}
<v-icon v-if="color === 'success'" >fas fa-thumbs-up</v-icon>
<v-icon v-else >fas fa-thumbs-down</v-icon>
</v-snackbar>
</template>
<script>
export default {
data () {
return {
timeout: '3000',
show: false,
message: '',
color: ''
}
},
created () {
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'snackbar/showMessage') {
this.message = state.snackbar.content
this.color = state.snackbar.color
this.show = true
}
})
}
}
</script>
<style scoped>
::v-deep .v-snack__wrapper {
min-width: 0px;
}
</style>