1.在components下新建一個新建組件頁面,以下所示vue
2.新建完成以後初始頁面的代碼以下所示:element-ui
3.下面從element-ui上找一個頂部導航菜單寫到組件頁面。測試
<el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b"> <el-menu-item index="1">處理中心</el-menu-item> <el-submenu index="2"> <template slot="title">個人工做臺</template> <el-menu-item index="2-1">選項1</el-menu-item> <el-menu-item index="2-2">選項2</el-menu-item> <el-menu-item index="2-3">選項3</el-menu-item> <el-submenu index="2-4"> <template slot="title">選項4</template> <el-menu-item index="2-4-1">選項1</el-menu-item> <el-menu-item index="2-4-2">選項2</el-menu-item> <el-menu-item index="2-4-3">選項3</el-menu-item> </el-submenu> </el-submenu> <el-menu-item index="3" disabled>消息中心</el-menu-item> <el-menu-item index="4"><a href="https://www.ele.me" target="_blank">訂單管理</a></el-menu-item> </el-menu>
1.引入組件ui
import MinorTopMenu from '~/components/MinorTopMenu.vue'
2.註冊組件spa
components: {
MinorTopMenu
}
3.使用組件code
<MinorTopMenu></MinorTopMenu>
4.頁面代碼截圖component
打開頁面,以下所示,說明組件使用成功blog
說明:本文爲原創做品,如有參考會在文中說起,若有遺漏,涉及侵權,請聯繫本人,將當即修正。element