Commit 6b1938ed authored by 吕 成东's avatar 吕 成东
Browse files

修复 tabs 点击切换

parent 2ef555e6
Pipeline #3083 canceled with stages
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from 'vue' import { onMounted, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import Swiper from 'swiper' import Swiper from 'swiper'
import { Navigation, Pagination, Autoplay } from 'swiper/modules' import { Navigation, Pagination, Autoplay } from 'swiper/modules'
import 'swiper/css' import 'swiper/css'
import 'swiper/css/pagination' import 'swiper/css/pagination'
import 'swiper/css/navigation' import 'swiper/css/navigation'
const router = useRouter()
const route = useRoute()
const navItems = [
{ name: '首 页', path: '/' },
{ name: '产品技术', path: '/products' },
{ name: '客户名录', path: '/customers' },
{ name: '新闻资讯', path: '/news' },
{ name: '加入我们', path: '/join' },
{ name: '关于我们', path: '/about' }
]
const handleNavClick = (path: string) => {
router.push(path)
}
onMounted(() => { onMounted(() => {
new Swiper('.swiper-container', { new Swiper('.swiper-container', {
modules: [Navigation, Pagination, Autoplay], modules: [Navigation, Pagination, Autoplay],
...@@ -31,12 +48,14 @@ onMounted(() => { ...@@ -31,12 +48,14 @@ onMounted(() => {
<div class="center-width header-top"> <div class="center-width header-top">
<i class="logo"></i> <i class="logo"></i>
<ul class="navigation"> <ul class="navigation">
<li class="active">首 页</li> <li
<li>产品技术</li> v-for="item in navItems"
<li>客户名录</li> :key="item.path"
<li>新闻资讯</li> :class="{ active: route.path === item.path }"
<li>加入我们</li> @click="handleNavClick(item.path)"
<li>关于我们</li> >
{{ item.name }}
</li>
</ul> </ul>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
...@@ -65,4 +84,8 @@ onMounted(() => { ...@@ -65,4 +84,8 @@ onMounted(() => {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
} }
.navigation li {
cursor: pointer;
}
</style> </style>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment