提交 90888dcf 编写于 作者: W weixin_39458544

Fri Sep 15 03:01:00 CST 2023 inscode

上级 37811b15
...@@ -7,6 +7,9 @@ import TheWelcome from './components/TheWelcome.vue' ...@@ -7,6 +7,9 @@ import TheWelcome from './components/TheWelcome.vue'
<router-view></router-view> <router-view></router-view>
</template> </template>
<style scoped> <style>
*{
margin: 0;
padding: 0;
}
</style> </style>
<template> <template>
<header> <header>
<ul class="__nav"> <ul class="__nav">
<li v-for="item in menus" :key="'menu_' + item.name">{{ item.name }}</li> <li @click="handleMenu(item)" v-for="item in menus" :key="'menu_' + item.name">{{ item.name }}</li>
</ul> </ul>
</header> </header>
</template> </template>
<script setup> <script setup>
const menus = [ import { useRouter } from 'vue-router';
{ name: '首页', path: '/' }, const menus = [
{ name: '关于我们', path: '/about' } { name: '首页', path: '/' },
] { name: '关于我们', path: '/about' }
]
const router = useRouter()
const handleMenu = (item) => {
router.push({
path: item.path
})
}
</script> </script>
<style lang="stylus"> <style scoped>
.__nav{ .__nav {
li{ display: flex;
list-style none; }
}
.__nav li {
list-style: none;
padding: 10px 20px;
cursor: pointer;
} }
</style>
\ No newline at end of file .__nav li:hover {
background-color: #177fff;
color: #fff;
}</style>
\ No newline at end of file
import {createRouter, createWebHashHistory} from 'vue-router' import {createRouter, createWebHashHistory} from 'vue-router'
import layout from '../layout/index.vue' import layout from '../layout/index.vue'
import home from '../views/home.vue' import home from '../views/home.vue'
import about from '../views/about.vue'
const subRouter = [ const subRouter = [
{path: '/', component: home} {path: '/', component: home},
{path: '/about', component: about}
] ]
const routes = [ const routes = [
......
<template>
<div>关于我们</div>
</template>
<script setup>
console.log('home')
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册