1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <!-- switch切换组件 --> <template> <div class='MoneyNumberSwitch'> <template v-for="(item, index) in list" :key="index+'switchBox'"> <div @click="moneyNumberSwitch(item.value,index)" class="switchBox" :class="{ 'active': indexTab == index }"> {{ item.label }}</div> </template> </div> </template> <script> import { reactive, shallowReactive, watch, ref, onBeforeMount, onMounted, nextTick, defineProps, defineEmits ,onUpdated} from 'vue'
export default { name: 'MoneyNumberSwitch', components: { } } </script> <script setup> const props = defineProps({ list:{ type:Array, default(){ return [] } }, indexTab:{ type:[String,Number], default:"0" } }) const emits = defineEmits(['update:indexTab','tabsChange']) const moneyNumberSwitch=(type,index)=>{ emits('update:indexTab',index) emits('moneyNumberSwitch',type,index) }
</script> <style scoped lang='less'> .MoneyNumberSwitch { width: 140px; height: 25px; border-radius: 15px; background-color: #D4E4FF; justify-content: space-between; display: flex; border: 1px solid #2779FF; .switchBox { width: 70px; height: 25px; text-align: center; line-height: 25px; font-size: 13px; cursor: pointer; color: #2779FF; transition: all linear .3s; border-radius: 15px; }
.active { background-color: #2779FF; color: #FFFFFF; } } </style>
|