前言
大家好 我是歌谣 今天又要进行新的技术栈的理解和开发了
第一步
需求是增加两个菜单进行页面的编写
先看看页面的结构
修改代码如下
<div v-if="index === 0"><tool-outlined style="font-size: 40px" /></div>
<div v-if="index === 1">
<safety-certificate-outlined style="font-size: 40px" />
</div>
<div v-if="index === 2"><tool-outlined style="font-size: 40px" /></div>
<div v-if="index === 3"><safety-certificate-outlined style="font-size: 40px" /></div>
<h1>{{ item.name }}</h1>
数据定义部分
const menuList = ref<menuItem[]>([
{ id: 1, name: "生产", pathName: "current" },
{ id: 2, name: "质检", pathName: "qualitycontrol" },
{ id: 3, name: "下料", pathName: "blanking" },
{ id: 3, name: "报工", pathName: "reportingwork" },
]);
运行结果
接下来
接下来就是控制页面的跳转了 必然是需要配合路由进行页面跳转的所以就是要增加路由
{
path: 'blanking',
name: 'blanking',
redirect: '/blanking/blankinglist',
children: [
{
path: 'blankinglist',
name: 'blankinglist',
component: QCHome,
},
]
},
接着就是创建一个页面 路由指向文件所在的位置进行编写
<template>
<div>11111</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { ToolOutlined, SafetyCertificateOutlined } from "@ant-design/icons-vue";
import { useRouter } from "vue-router";
import { getUserInfo } from "@/api/base";
const router = useRouter();
interface menuItem {
id: number;
name: string;
pathName: string;
}
const menuList = ref<menuItem[]>([
{ id: 1, name: "生产", pathName: "current" },
{ id: 2, name: "质检", pathName: "qualitycontrol" },
{ id: 3, name: "下料", pathName: "blanking" },
{ id: 3, name: "报工", pathName: "reportingwork" },
]);
onMounted(() => {
init();
});
const init = async () => {
const response = await getUserInfo();
console.log(response);
};
const goHome = (pathName: string) => {
router.push({
name: pathName,
});
};
</script>
<style lang="less" scoped>
</style>