Maison > Questions et réponses > le corps du texte
P粉3005417982023-08-31 16:51:55
Votre logoTop
计算属性可以在样式绑定中用于设置v-img
的top
emplacement d'origine :
<template> <v-img :style="{ top: logoTop }" ... /> </template> <script> export default { computed: { logoTop() { switch (this.$vuetify.breakpoint.name) { case 'xl': return "-4%" case 'lg': return "-6%" case 'md': return "-8%" case 'sm': return "-8%" case 'xs': return 0 default: return "-4%" } }, } } </script>
P粉4623289042023-08-31 14:24:05
switch
Ne retournez rien. Vous devriez utiliser une variable comme celle-ci
logoTop() { let topProperty; switch (this.$vuetify.breakpoint.name) { case 'xl': topProperty = 400; break; case 'lg': case 'md': topProperty = 300; break; case 'sm': topProperty = 200; break; case 'xs': topProperty = 0; break; default: topProperty = 400; } return { "--top-property" : topProperty } },