我有一个组件,根据用户成员身份状态呈现文本,我想根据该属性值更改插值文本.除了一堆v-if
或v-show
的divs/p标签外,还有没有更有效的方式根据props 显示不同的文本?
总是有一堆叠在一起的div就是一堆文本.
任何建议都将不胜感激!
干杯
<script lang="ts" setup>
import { PropType } from 'vue'
const props = defineProps({
kind: {
type: String as PropType<'subscribed' | 'unsubscribed'>,
default: 'subscribed',
},
planId: {
type: String as PropType<'standard' | 'silver' | 'gold' | 'platinum' | 'diamond' | 'no plan'>,
default: 'standard',
},
})
</script>
<template>
<div class="c-promotion-plan-card" data-cy="component-promotion-plan-card">
<div class="flex items-baseline mb-sm">
<div v-if="planId === 'standard'" class="text-h6 text-dark">Standard Gang</div>
<div v-if="planId === 'silver'" class="text-h6 text-dark">Silver Foxes</div>
<div v-if="planId === 'gold'" class="text-h6 text-dark">Golden Girls</div>
<div v-if="planId === 'platinum'" class="text-h6 text-dark">Platinum Boys</div>
<div v-if="planId === 'diamond'" class="text-h6 text-dark">Diamond Dudes</div>
<div v-if="planId === 'no plan'" class="text-h6 text-dark">
No Plan Posse
</div>
</div>
</div>
</template>