mirror of
https://github.com/talktao/Vue3-Vite-Vant-TS-H5.git
synced 2025-04-23 18:00:21 +08:00
add:底部TabBar栏组件封装
This commit is contained in:
parent
a19322b34b
commit
812dff161d
44
src/components/TabBar.vue
Normal file
44
src/components/TabBar.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref } from 'vue'
|
||||||
|
|
||||||
|
interface tabProps {
|
||||||
|
data?: [
|
||||||
|
{
|
||||||
|
title: string
|
||||||
|
to: string
|
||||||
|
name: string
|
||||||
|
icon: string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<tabProps>()
|
||||||
|
console.log(props.data,'props.data');
|
||||||
|
|
||||||
|
|
||||||
|
const emit = defineEmits(['chang'])
|
||||||
|
|
||||||
|
const active = ref('home')
|
||||||
|
|
||||||
|
const onChange = (value) => {
|
||||||
|
console.log(value,'value');
|
||||||
|
|
||||||
|
emit('chang', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<van-tabbar fixed route v-model="active" @change="onChange">
|
||||||
|
<van-tabbar-item v-for="(item, index) in props.data" :to="item.to" :name="item.name" :key="index" :icon="item.icon">{{item.title}}</van-tabbar-item>
|
||||||
|
</van-tabbar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user