<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function dataTree(data) {
let parents = data.filter(c => c.pid == 0),
childrens = data.filter(c1 => c1.pid != 0);
tree(parents, childrens)
/**
* 求这先求出第一层的数据
*/
function tree(parents, childrens) {
parents.map((v, i1) => {
childrens.map((c, i) => {
if (v.id == c.pid) {
let _c = JSON.parse(JSON.stringify(childrens))
_c.splice(i, 1)
if (v.chil
Vue权限动态路由Array转成功Tree
最新推荐文章于 2023-09-15 15:05:23 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)