| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <template>
- <div class="tab-switcher">
- <div :class="{ active: selectedTab === 'latest' }" @click="selectTab('latest')">
- <span style="font-size: 10px">最新</span>
- </div>
- <div :class="{ active: selectedTab === 'hot' }" @click="selectTab('hot')">
- <span style="font-size: 10px">热门</span>
- </div>
- </div>
- </template>
- <script setup>
- import { ref } from 'vue'
- const emit = defineEmits(['selectTab'])
- const selectedTab = ref('latest')
- const selectTab = (tab) => {
- if (selectedTab.value != tab) {
- selectedTab.value = tab
- emit('selectTab', tab)
- }
- }
- </script>
- <style scoped>
- .tab-switcher {
- display: flex;
- border-radius: 20px;
- border: 1px solid #1e90ff;
- overflow: hidden;
- }
- .tab-switcher div {
- padding: 1px 15px;
- background-color: #f5f5f5;
- cursor: pointer;
- }
- .tab-switcher div.active {
- background-color: #1e90ff;
- color: white;
- }
- .tab-switcher div:not(:last-child) {
- }
- </style>
|