今天老师让我写一个树形结构,我通过查询资料写出来了一个,希望对大家有所帮助
<template>
<div>
<div class="wrap-row">
</div>
<el-tree :data="menu" :props="defaultProps"></el-tree>
</div>
</template>
<script>
export default {
data() {
return {
menu: [],
defaultProps: {
children: 'children',
label: 'label'
}
}
},
created(){
this.searchOrg();
},
methods: {
openAdd(){
this.$router.push("/user");
},
searchOrg(){
this.$axios.get("api/getStrOrganization").then(response=>{
console.log(response);
this.menu=response.data.data
console.log(this.menu)
})
},
}
}
</script>
<style scoped>
.wrap-row{
display: flex;
flex-direction: row;
}
.p{
margin-left: 200px;
}
</style>