> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/centos/vue/xiang-mu/2-09.-ce-bian-cai-dan-kai-fa-yang-shi-bu-ju-he-lu-you-tiao-zhuan.md).

# 2 09.侧边菜单开发 样式布局和路由跳转

> src/layouts/components/FMain.vue

```js
<template>
    <div class="f-menu">
        <el-menu default-active="2" class="border-0" @select="handleSelect">

        <template v-for="(item,index) in asideMenus" :key="index">
            <el-sub-menu v-if="item.child && item.child.length > 0" :index="item.name">
                <template #title>
                    <el-icon>
                        <component :is="item.icon"></component>
                    </el-icon>
                    <span>{{ item.name }}</span>
                </template>

                <el-menu-item v-for="(item2,index2) in item.child" :key="index2" :index="item2.frontpath">
                    <el-icon>
                        <component :is="item.icon"></component>
                    </el-icon>
                    <span>{{ item.name }}</span>
                </el-menu-item>
            </el-sub-menu>


            <el-sub-menu v-else :index="item.frontpath">
                    <el-icon>
                        <component :is="item.icon"></component>
                    </el-icon>
                    <span>{{ item.name }}</span>
            </el-sub-menu>
        </template>

        </el-menu>
</div>
</template>


<script setup> 
import { useRouter } from "vue-router"

const router = useRouter()
// 自定义一些测试路由
const asideMenus = [
    {
        "name": "后台面板",
        "icon": "help",
        "child": [{
            "name": "主控台",
            "icon": "home-filled",
            "frontpath": "/",
        }]
    },
    {
        "name": "商城管理",
        "icon": "shopping-bag",
        "child": [{
            "name": "商品管理",
            "icon": "home-filled",
            "frontpath": "/good/list",
        }]
    },
]


const handleSelect = (e)=> {
    // console.log(e)
    router.push(e)
}

</script>


<style>
.f-menu {
    width: 250px;
    height: 100%;
    top: 64px;
    left: 0;
    overflow: auto;
    @apply shadow-md fixed bg-light-50;
}
</style>
```

<div><img src="C:%5CUsers%5CAdministrator.DESKTOP-UK43ECI%5CAppData%5CRoaming%5Cmarktext%5Cimages%5C2023-02-21-14-29-53-image.png" alt=""> <figure><img src="/files/Z93gfz41sDMEcM8qAlD6" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/centos/vue/xiang-mu/2-09.-ce-bian-cai-dan-kai-fa-yang-shi-bu-ju-he-lu-you-tiao-zhuan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
