Browse Source

修改

master
wen 2 years ago
parent
commit
513069b3c6
  1. 46
      src/layout/components/Sidebar/index.vue
  2. 2
      src/layout/components/Sidebar/leftMenusData.js

46
src/layout/components/Sidebar/index.vue

@ -33,10 +33,11 @@ export default { @@ -33,10 +33,11 @@ export default {
components: { SidebarItem, Logo },
created: function () {
this.getmunusdata();
this.menusdatas = 66
},
data() {
return {
routes:menusdata
//routes:this.menusdatas
}
},
computed: {
@ -67,43 +68,44 @@ export default { @@ -67,43 +68,44 @@ export default {
},
methods: {
SplicingMenuTree(menus, menusdatas) {
// console.log(menus);
// console.log(menusdatas);
// console.log(this.routes[0]);
SplicingMenuTree(menus) {
let newMenu = null, arrMenus = [];
menus.forEach(item => {
//console.log(menusdata[0]);
if (!menusdatas.children) {
this.$set(menusdatas,'children', [])
//menusdata[0].children = []
}
// if (!this.menusdata.children) {
// this.$set(this.menusdata,'children', [])
// //menusdata[0].children = []
// }
//Object.assign(menusdata[0],)
menusdatas.children.push(
{
path: '/subfile?id='+item.id,
meta: { title: item.directory, icon: 'dashboard' }
}
);
newMenu = {
path: '/subfile?id='+item.id,
meta: { title: item.directory, icon: 'dashboard' },
children:[]
}
//console.log(item.directories.length);
if (item.directories && item.directories.length > 0) {
this.SplicingMenuTree(item.directories, menusdatas.children[item.directories.length-1])
newMenu.children = this.SplicingMenuTree(item.directories,)
}
arrMenus.push(newMenu);
console.log(arrMenus);
return arrMenus;
});
console.log(menusdata[0].children);
},
getmunusdata() {
let thiss = this;
console.log(this.$route);
console.log(this.$store);
// console.log(this.$route);
// console.log(this.$store);
mirlist().then(response => {
let datamain = response.data;
//routesData(datamain.data.menus);
//console.log(response);
this.SplicingMenuTree(datamain.data.menus, menusdata[0]);
console.log(this.menusdatas);
this.menusdatas = this.SplicingMenuTree(datamain.data.menus);
console.log(this.menusdatas);
//this.routes = menusdata
//console.log(menusdata);

2
src/layout/components/Sidebar/leftMenusData.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
// 菜单栏生成
let menusdata = [
var menusdata = [
// {
// id: '0',

Loading…
Cancel
Save