第一步:在script中写入:
created() {
this.getmenuList()
},
第二步:在created下面写入:
methods: {
// 获取所有的菜单数据
async getmenuList() {
// get或post方法
const { data: res } = await this.$http.POST("/system/cfg/menu");
if(res.meta.status !== 200) return this.$message.error();
this.menuList = res.data
console.log(res);
},
}
第三步:在template中写入:
<el-submenu index="1" v-for="item in menuList" :key="item.id">
<template slot="title">
<i class="el-icon-monitor"></i>
<span style="font-family: '等线'">{{item.authName}}</span>
</template>
</el-submenu>
vue 调用后台数据的方法
于 2022-02-14 15:10:04 首次发布