34、shell数组+正则表达式命令

news2025/2/27 4:52:55

0、课前补充

在这里插入图片描述

jiafa () {
result=$(echo " $1 + $2 " | bc )
print "%.2f\n" "$result"
}                   ##保留小数点两位 

薄弱加强点

a=$(df -h | awk 'NR>1 {print $5}' | tr -d '%')
echo "$a"

在这里插入图片描述

一、数组

1.1、定义

数组的定义:在集合种指定多个元素。

1.2、元素类型

元素的类型:整数,字符串,可以是浮点。

1.3、数组的作用

数组的作用:一次性的定义多个元素,可以为变量赋值提供便利。

1.4、数组的定义方法:

1.4.1、数组的格式

数组名= (a b c d)

数组名不能重复

在这里插入图片描述

[root@test1 opt]# vim test56.sh 
[root@test1 opt]# test1=(a b c d)
[root@test1 opt]# echo ${test1[*]}
a b c d
[root@test1 opt]# echo ${test1[@]}
a b c d
[root@test1 opt]# test2[0]=1
[root@test1 opt]# test2[1]=2
[root@test1 opt]# test2[2]=3
[root@test1 opt]# echo ${test2[@]}
1 2 3

1.4.2、数组的长度

#数组的长度指的是:数组内包含了几个元素。

打印出数组的长度:

echo ${#数组名[*]} 

例子:

echo ${#test[*]}  ##打印数组内包含了几个元素

[root@test1 opt]# echo ${#test1[*]}
4
[root@test1 opt]# echo ${#test2[*]}
3

1.4.3、查看数组指定位置元素—开始为0

echo ${数组名[下标]}

例子:

[root@test1 opt]# test3=(abc 123 456 789 dahanqi)
[root@test1 opt]# echo ${test3[0]}
abc
[root@test1 opt]# echo ${test3[2]}
456
[root@test1 opt]# echo ${test3[3]}
789

1.4.4、数组遍历

[root@test1 opt]# vim shuzu.sh

#数组遍历
test=(1 2 3 4 5)
for num in ${test[*]}
do
echo -ne "$num\t"
done



[root@test1 opt]# sh shuzu.sh
1	2	3	4	5	

1.4.5、数组的切片

echo ${数组名[*]:下标:打印长度}

例子:

[root@test1 opt]# test5=(1 2 3 4 5)
[root@test1 opt]# echo ${test5[*]}
1 2 3 4 5
[root@test1 opt]# echo ${test5[*]:0:2}
1 2

在这里插入图片描述

在这里插入图片描述

#0表示起始位置,2表示步长,起始位置θ开始,包括0,移2个。

[root@test1 opt]# echo ${test5[*]:1:3}
2 3 4

1.4.6、数组的替换

#临时替换

echo ${数组名[*]/下标/数值}

例子:

[root@test1 opt]# echo ${test5[*]/4/99}
1 2 3 99 5    ##临时替换

#永久修改

通过修改元素下标的值可以实现----赋值覆盖。

[root@test1 opt]# echo ${test5[*]}
1 2 3 4 5
[root@test1 opt]# echo ${test5[*]/4/99}
1 2 3 99 5    ##临时替换
[root@test1 opt]# echo ${test5[*]}
1 2 3 4 5
[root@test1 opt]# test5[3]=99  ##重新赋值覆盖替换
[root@test1 opt]# echo ${test5[*]}
1 2 3 99 5

1.4.7、删除数组

#删除整个数组

unset 数组名

例子:

[root@test1 opt]# echo ${test1[*]}
a b c d
[root@test1 opt]# unset test1
[root@test1 opt]# echo ${test1[*]}

[root@test1 opt]# echo ${test1[*]}

[root@test1 opt]#

1.4.8、删除元素

#删除数组当中的元素—通过单个下标删除

unset 数组名[下标]

例子:

[root@test1 opt]# echo ${test5[*]}
1 2 3 99 5
[root@test1 opt]# unset test5[2]
[root@test1 opt]# echo ${test5[*]}
1 2 99 5
[root@test1 opt]# echo ${test5[3]}
99
[root@test1 opt]# echo ${test5[2]}

1.4.9、数组追加,追加元素

数组名[下标]=数值

根据下标追加

[root@test1 opt]# test5[4]=5
[root@test1 opt]# echo ${test5[*]}
1 2 3 99 5
[root@test1 opt]# test5[5]=6
[root@test1 opt]# echo ${test5[*]}
1 2 3 99 5 6

在尾部追加

数组名+=(x  y)

例子:

[root@test1 opt]# test5+=(7 8)
[root@test1 opt]# echo ${test5[*]}
1 2 3 99 5 6 7 8

#现在定义一个数组,元素都是整数,实现数组内整数的累加求和

在这里插入图片描述

test1=(10 20 30 40 50 60)
b=0
for ((i=0;i<6;i++))
do
a=`echo ${test1[i]}`
b=$(($a+$b))
done
echo $b

[root@test1 opt]# vim shuzu1.sh
[root@test1 opt]# sh shuzu1.sh
210

在这里插入图片描述

[root@test1 opt]# vim shuzu1.sh



test1=(10 43 45 47 50 60)
sum1=0
sum2=0
for i in ${test1[*]}
do
if [[ $i%2 -eq 0 ]]
then
sum1=$(($sum1+$i))
else
sum2=$(($sum2+$i))
fi
done
echo $sum1
echo $sum2



[root@test1 opt]# sh shuzu1.sh
120
135

在这里插入图片描述

root@test1 opt]# vim shuzu2.sh

test1=(3 5 8 4 56 34 76 53)
max=${test1[0]}
min=${test1[0]}
for i in ${test1[*]}
do
 if [ $i -gt $max ]
  then         
  max=$i           ##取数组里面大于的话,赋值给max,小于等于不用管
  fi
 if [ $i -lt $min ]
 then
  min=$i              ##取数组里面小于的话,赋值给min,大于等于不用管
  fi
done
echo "$max"
echo "$min"



[root@test1 opt]# sh shuzu2.sh
76
3

1.5、冒泡排序

在这里插入图片描述


#冒泡排序:#类似气泡上涌的工作,会将数组当中的元素按照从小到大,或>者从大道小的顺序进行一个重新排列。test1=(20 10 60 40 50 30)
#从小到大排列。
#思路:对比两个相邻的元素,以从小到大为例。满足交换条件的元素,小的
往左移,大的往右移动。
#数组的位置发生变化(下标对应的元素的值发生变化)
#双层循环,外部循环控制排序的轮次。内循环比较两个元素的大小,决定>时候互换位置
#对比和交换的次数随着排序轮次而减少


[root@test1 opt]# vim shuzu3.sh
test1=(20 10 60 40 50 30)
length=${#test1[*]}
for ((b=1;b<length;b++))
do
for ((a=0;a<=length-b;a++))
do
  c=${test1[$a]}
  d=${test1[(($a+1))]}
  if [ $c -gt $d ]
  then
   e=$c
   test1[$a]=$d
   test1[(($a+1))]=$c
fi
done
done
echo "${test1[*]}"



[root@test1 opt]# sh shuzu3.sh
10 20 30 40 50 60

总结:取最大值,内循环,第一次循环需要,length-1次内循环,最大值在最后,a++后,b++,外循环第二次,这时候最大值已经在最后一位,那么内循环此时需要进行length-2次,依次类推

详见下:

  • [root@test1 opt]# bash -x shuzu3.sh
    
    + test1=(20 10 60 40 50 30)
    + length=6
    + (( b=1 ))
    + (( b<length ))
    + (( a=0 ))
    + (( a<length-b ))
    + c=20
    + d=10
    + [[ 20 -gt 10 ]]
    + e=20
    + test1[$a]=10
    + test1[(($a+1))]=20
    + (( a++ ))
    + (( a<length-b ))
    + c=20
    + d=60
    + [[ 20 -gt 60 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=60
    + d=40
    + [[ 60 -gt 40 ]]
    + e=60
    + test1[$a]=40
    + test1[(($a+1))]=60
    + (( a++ ))
    + (( a<length-b ))
    + c=60
    + d=50
    + [[ 60 -gt 50 ]]
    + e=60
    + test1[$a]=50
    + test1[(($a+1))]=60
    + (( a++ ))
    + (( a<length-b ))
    + c=60
    + d=30
    + [[ 60 -gt 30 ]]
    + e=60
    + test1[$a]=30
    + test1[(($a+1))]=60
    + (( a++ ))
    + (( a<length-b ))
    + (( b++ ))
    + (( b<length ))
    + (( a=0 ))
    + (( a<length-b ))
    + c=10
    + d=20
    + [[ 10 -gt 20 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=20
    + d=40
    + [[ 20 -gt 40 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=40
    + d=50
    + [[ 40 -gt 50 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=50
    + d=30
    + [[ 50 -gt 30 ]]
    + e=50
    + test1[$a]=30
    + test1[(($a+1))]=50
    + (( a++ ))
    + (( a<length-b ))
    + (( b++ ))
    + (( b<length ))
    + (( a=0 ))
    + (( a<length-b ))
    + c=10
    + d=20
    + [[ 10 -gt 20 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=20
    + d=40
    + [[ 20 -gt 40 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=40
    + d=30
    + [[ 40 -gt 30 ]]
    + e=40
    + test1[$a]=30
    + test1[(($a+1))]=40
    + (( a++ ))
    + (( a<length-b ))
    + (( b++ ))
    + (( b<length ))
    + (( a=0 ))
    + (( a<length-b ))
    + c=10
    + d=20
    + [[ 10 -gt 20 ]]
    + (( a++ ))
    + (( a<length-b ))
    + c=20
    + d=30
    + [[ 20 -gt 30 ]]
    + (( a++ ))
    + (( a<length-b ))
    + (( b++ ))
    + (( b<length ))
    + (( a=0 ))
    + (( a<length-b ))
    + c=10
    + d=20
    + [[ 10 -gt 20 ]]
    + (( a++ ))
    + (( a<length-b ))
    + (( b++ ))
    + (( b<length ))
    + echo '10 20 30 40 50 60'
      10 20 30 40 50 60
    

二、正则表达式

正则表达式:匹配的是文本内容,linux的文本三剑客都是针对文本内容。

grep 过滤文本内容

sed 针对文本内容进行增删改查

awk 按行取列

文本三剑客----都是按照行进行匹配。

2.1、grep筛选:

grep的作用就是使用正则表达式来匹配文本内容。

选项:

-m 数字 匹配几次之后停止

[root@test1 opt]# grep -m 1 root /etc/passwd
root:x:0:0:root:/root:/bin/bash
[root@test1 opt]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

-v 取反

grep -v root /etc/passwd   ##除了root,筛选所有

-n 显示匹配的内容及行号

[root@test1 opt]# grep -n root /etc/passwd
1:root:x:0:0:root:/root:/bin/bash
10:operator:x:11:0:operator:/root:/sbin/nologin

-c 只统计匹配的行数

[root@test1 opt]# grep -c root /etc/passwd 
2

-o 仅显示匹配的结果

[root@test1 opt]# grep -o root /etc/passwd 
root
root
root
root

-q 静默模式。不输出任何信息。

[root@test1 opt]# grep -q root /etc/passwd > /opt/123.txt
[root@test1 opt]# cat /opt/123.txt
[root@test1 opt]# grep -m 1 root /etc/passwd > /opt/123.txt
[root@test1 opt]# cat /opt/123.txt
root:x:0:0:root:/root:/bin/bash

-A after 数字,后几行

grep -A 3 root /etc/passwd

-B before 数字 ,前几行

grep -B 3 root /etc/passwd

-C 数字,前后各几行

grep -C 3 root /etc/passwd

-e 或者

 grep -e root -e xy102 /etc/passwd

-E 匹配扩展正则表达式

-f 匹配两个文件相同的内容,以第一个文件为准

[root@test1 opt]# vim kl1.txt
abc
acv
abf123
234
456
aaa
bbb
ccc
abc
acv
abf123
234
456
aaa
bbb
ccc
abc
acv
abf


[root@test1 opt]# vim kl1.txt

123
345
qqq
aaa
abf
avg
afh


[root@test1 opt]# grep -f kl.txt kl1.txt
123
aaa
abf


-r 递归目录 目录下的文件内容,软连接不包含在内。

[root@test1 opt]# grep -r 123 /opt/
/opt/test41.sh:  echo 123 | passwd --stdin $user
/opt/test41.sh:  echo 123 | passwd --stdin $user
匹配到二进制文件 /opt/.123.swp

-R 递归目录 目录下的文件内容,软连接包含在内。

[root@test1 opt]# grep -R abf /opt/
/opt/nginx-1.22.0/src/core/ngx_crc32.c:    0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
/opt/999.txt:abf123

2.2、sort排序:

sort

以行为单位,对文件的内容进行排序

sort 选项 参数

[root@test1 opt]# sort 123.txt





111
112
123
222
333
555
aaa
aaa
aaa
bbb
bbb
cc
ddd
DDD
EEE
nnn

cat file | sort 选项

-f 忽略大小写,默认会把大写字母排在前面

[root@test1 opt]# sort -f 123.txt





111
112
123
222
333
555
aaa
aaa
aaa
bbb
bbb
cc
DDD
ddd
EEE
nnn

-b 忽略每行之前的空格(不是把空格删除,只是按照数字和字母的顺序排列)

[root@test1 opt]# sort -b 123.txt




​	
 123
345
345
 345
567
987
aaa
bbb
bbb
BD
bfvf
SD
sdfd
sds

-n 按照数字进行排序

[root@test1 opt]# sort -n 123.txt




​	
aaa
bbb
bbb
BD
bfvf
SD
sdfd
sds
 123
345
345
 345
567
987

-r 反向排序

[root@test1 opt]# sort -r 123.txt
sds
sdfd
SD
bfvf
BD
bbb
bbb
aaa
987
567
 345
345
345
 123
	

-u 相同的数据只显示一行

[root@test1 opt]# sort -u 123.txt

	
 123
345
 345
567
987
aaa
bbb
BD
bfvf
SD
sdfd
sds

-o 把排序后结果转存到指定的文件

[root@test1 opt]# sort -u 123.txt


 123
345
 345
567
987
aaa
bbb
BD
bfvf
SD
sdfd
sds
[root@test1 opt]# cat 123.txt | sort -rno 234.txt
[root@test1 opt]# cat 234.txt
987
567
 345
345
345
 123
sds
sdfd
SD
bfvf
BD
bbb
bbb
aaa

2.3、uniq 去重

uniq 去除连续重复的行,只显示一行

-c 统计连续行的次数,合并连续重复的行

[root@test1 opt]# uniq -c 123.txt
      1  345
      1 567
      1 987
      1  123
      2 345
      1 bbb
      1 bfvf
      2 
      1 sdfd
      1 SD
      1 BD
      2 
      1 	
      1 sds
      2 aaa
      1 bbb

-u 显示仅出现一次的行(包括不适合连续出现的重复行)

[root@test1 opt]# uniq -u 123.txt
 345
567
987
 123
bbb
bfvf
sdfd
SD
BD
	
sds
bbb


-d 仅显示连续重复的行(不包括非连续出现的内容)

[root@test1 opt]# uniq -d 123.txt   ##显示重复的行
345                          


aaa

作业

[root@test1 ~]# df -h | awk 'NR>1 {print  $5}' | tr -d '%'
15
0
0
1
0
100
18
1
0
1

#按照从大到小排列

#附加题从小到大,整行排序

test1=($(df -h | awk 'NR>1 {print $5}' | tr -d '%'))
echo "原数组的排序为:${test1[*]}"
length=${#test1[*]}
for ((j=1;j<$length;j++))
do
 for ((k=0;k<$length-j;k++))
 do
  a=${test1[$k]}
  b=${test1[$(($k+1))]}
  if [ $a -lt $b ]
   then
    c=$b
    test1[$k]=$c
    test1[$(($k+1))]=$a
    fi
done
done
echo "数组从大到小的排序为:${test1[*]}"
df -h | awk 'NR>1 {print $0, $5}' | sort -k5  -nr

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1854047.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

多分类情绪识别模型训练及基于ChatGLM4-9B的评论机器人拓展

你的下一个微博罗伯特何必是罗伯特 这是一篇我在使用开源数据集(Twitter Emotion Dataset (kaggle.com))进行情绪识别的分类模型训练及将模型文件介入对话模型进行应用的过程记录。当通过训练得到了可以输入新样本预测的模型文件后&#xff0c;想到了或许可以使用模型文件对新样…

【数据结构导论】自考笔试题:伪代码练习题汇总 1

目录 一、开源项目推荐 二、线性表的基本运算在单链表上的实现 &#xff08;1&#xff09;初始化 &#xff08;2&#xff09;插入 p 指向的新结点的操作 &#xff08;3&#xff09;删除 *p 节点 三、循环链表 &#xff08;1&#xff09;在单链表中 &#xff08;2&…

Spring Boot 实现微信、QQ 绑定登录

文章目录 1. 项目环境2. 创建Spring Boot项目3. 配置微信和QQ开发平台4. 配置Spring Security5. 配置Spring Security6. 创建登录和主页控制器7. 创建视图8. 运行项目9. 处理用户信息结论 &#x1f389;欢迎来到SpringBoot框架学习专栏~ ☆* o(≧▽≦)o *☆嗨~我是IT陈寒&#…

JAVA复习4

目录 44、定义 int x5; 执行 int yx; 和 xy;&#xff0c;x 和 y 分别为&#xff08; B &#xff09;。 45、下列内容描述错误的是&#xff08; C &#xff09;。 46、以下 Java 语句在编译时不通过的是 (A) 47、在 Java 中&#xff0c;Scanner 类提供控制台获取键盘输入的功…

皇河将相董事长程灯虎出席第二十四届世纪大采风并获奖

仲夏时节,西子湖畔。第二十四届世纪大采风品牌人物年度盛典于6月16日至17日在杭州东方文化园隆重举行。本届盛典由亿央网、《华夏英才》电视栏目联合多家媒体共同主办,中世采文化发展集团承办,意尔康股份有限公司、宸咏集团协办,汇聚了来自全国政、商、产、学、研、媒等各界代表…

4.1 四个子空间的正交性

一、四个子空间的正交性 如果两个向量的点积为零&#xff0c;则两个向量正交&#xff1a; v ⋅ w v T w 0 \boldsymbol v\cdot\boldsymbol w\boldsymbol v^T\boldsymbol w0 v⋅wvTw0。本章着眼于正交子空间、正交基和正交矩阵。两个子空间的中的向量&#xff0c;一组基中的向…

【2024最新版】Java JDK安装配置全攻略:图文详解

目录 1. 引言2. 准备工作2.1 **确定操作系统**2.2 **检查系统要求**2.3 **下载JDK安装包**3. 安装步骤&#xff08;以Windows系统为例&#xff09;4. 配置环境变量4.1 jdk配置验证4.2 **配置JAVA_HOME环境变量**4.3 **配置Path环境变量**4.4 验证jdk是否配置成功 5. 结语 1. 引…

MySQL命名规范(自用)

MtySQL命名规范 基本通用规范 1.【推荐】关键字必须大写 所有关键字必须大写&#xff0c;如&#xff1a;INSERT、UPDATE、DELETE、SELECT及其子句&#xff0c;IF……ELSE、CASE、DECLARE等 2.【强制】字段和建表必须写备注 COMMENT写备注 3.【强制】字母数字下划线 采用26个英…

CentOS 7、Debian、Ubuntu,这些是什么意思

CentOS 7、Debian、Ubuntu 都是基于 Linux 内核的操作系统&#xff0c;它们各自有不同的特性和用途。以下是对它们的详细解释&#xff1a; CentOS 7 CentOS&#xff08;Community ENTerprise Operating System&#xff09; 是一个基于开源的 Linux 发行版。CentOS 7 是 CentOS …

JavaScript的学习之旅之初始JS

目录 一、认识三个常见的js代码 二、js写入的第二种方式 三、js里内外部文件 一、认识三个常见的js代码 <script>//写入js位置的第一个地方// 控制浏览器弹出一个警告框alert("这是一个警告");// 在计算机页面输入一个内容&#xff08;写入body中&#xff…

支付系统的渠道路由架构设计

图解支付系统的渠道路由设计 渠道路由是引导流量路径的关键&#xff0c;其设计至关重要。本文详解渠道路由概念、必要性及形态&#xff0c;并分享一个高效实用的基于规则的渠道路由设计方案。 注&#xff1a;有些公司称渠道为通道&#xff0c;都是一个意思&#xff0c;为方便起…

(南京观海微电子)——DC-DC和LDO的原理及应用区别

LDO: 低压差线性稳压器&#xff0c;故名思意为线性的稳压器&#xff0c;仅能使用在降压应用中&#xff0c;也就是输出电压必需小于输入电压。 优点&#xff1a;稳定性好&#xff0c;负载响应快&#xff0c;输出纹波小。 缺点&#xff1a; 效率低&#xff0c;输入输出的电压…

Spring响应式编程之Reactor介绍

Reactor介绍 1、异步执行技术2、实现方式 响应式编程&#xff08;Reactive Programming&#xff09;是一种面向数据流和变化传播的编程范式。Java中的Reactor是一个用于响应式编程的库&#xff0c;它建立在Reactive Streams规范之上&#xff0c;旨在帮助开发者构建非阻塞的、高…

vue登陆密码加密,java后端解密

前端 安装crypto-js npm install crypto-js加密 //引入crypto-js import CryptoJS from crypto-js;/** ---密码加密 start--- */ const SECRET_KEY CryptoJS.enc.Utf8.parse("a15q8f6s5s1a2v3s"); const SECRET_IV CryptoJS.enc.Utf8.parse("a3c6g5h4v9sss…

项目-博客驿站测试报告

测试用例设计 功能测试 该部分主要围绕对于博客系统的增删改查, 文章通过性审核, 关注功能等进行测试, 还进行了其它一些探索性的测试. 以上是作者设计的全部用例. BUG发现: 问题1: 当多端同时操作同一篇文章BUG 环境: Windows11, Edge和Chrome浏览器 复现步骤: 1.先使用Edg…

《三国:谋定天下》成为了SLG游戏现象级的成功案例

原标题&#xff1a;《三国&#xff1a;谋定天下》引领SLG游戏新潮流&#xff0c;B站股价五个飙升了30% 易采游戏网6月23日&#xff1a;B站作为年轻人喜爱的文化社区和视频平台&#xff0c;再次用一款新的游戏证明了其在游戏发行领域的独到眼光与强大实力。最近大火的策略角色扮…

VBA学习(17):使用条件格式制作Excel聚光灯

今天给大家分享的表格小技巧是制作聚光灯。 先说一下啥是聚光灯。所谓聚光灯&#xff0c;可以简单理解为对工作表的行列填充颜色&#xff0c;突出显示被选中的单元格&#xff0c;仿佛该单元格被聚光灯照亮似的。聚光灯有助于肉眼识别所选中的单元格或区域&#xff0c;提高数据…

Repair LED lights

Repair LED lights 修理LED灯&#xff0c;现在基本用灯带&#xff0c;就是小型LED灯串联一起的 1&#xff09;拆旧灯条&#xff0c;这个旧的是用螺丝拧的产品 电闸关掉。 2&#xff09;五金店买一个&#xff0c;这种是磁铁吸附的产品 现在好多都是铝线啊。。。 小部件&#x…

2024最新最全的车载测试教程__各模块测试用例

二、设计用例方法 1.测试用例设计前&#xff1a; a.仔细认真研读prd、理解prd b.质疑prd、有困惑或者想法的点做好记录&#xff0c;可以一次性和产品沟通 2.设计中&#xff1a; 成282 a.根据结构化思维&#xff0c;设计xmind i全链路正向功能点、子链路功能点 ⅱ.考虑业…

15.树形虚拟列表实现(支持10000+以上的数据)el-tree(1万+数据页面卡死)

1.问题使用el-tree渲染的树形结构&#xff0c;当数据超过一万条以上的时候页面卡死 2.解决方法&#xff1a; 使用vue-easy-tree来实现树形虚拟列表&#xff0c;注意&#xff1a;vue-easy-tree需要设置高度 3.代码如下 <template><div class"ve-tree" st…