Rumah > Soal Jawab > teks badan
P粉3005417982023-08-31 16:51:55
Lokasi logoTop
计算属性可以在样式绑定中用于设置v-img
的top
asal anda:
<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
Tiada pulangan. Anda harus menggunakan pembolehubah seperti ini
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 } },