安装Harbor

news2024/11/15 22:54:35

前言

Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,虽然Docker官方也提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署企业内部的私有环境Registry是非常必要的,Harbor和docker中央仓库的关系,就类似于nexus和Maven中央仓库的关系,Harbor除了存储和分发镜像外还具有用户管理,项目管理,配置管理和日志查询,高可用部署等主要功能。

安装Harbor

安装之前需要安装Docker和Docker-Compose,本文不再赘述。版本查看:

[root@localhost harbor]# docker version
Client: Docker Engine - Community
 Version:           23.0.2
 API version:       1.42
 Go version:        go1.19.7
 Git commit:        569dd73
 Built:             Mon Mar 27 16:18:54 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          23.0.2
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.19.7
  Git commit:       219f21b
  Built:            Mon Mar 27 16:16:31 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20
  GitCommit:        2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc:
  Version:          1.1.5
  GitCommit:        v1.1.5-0-gf19387a
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

[root@localhost harbor]# docker compose version
Docker Compose version v2.20.2

下载Harbor压缩包并解压,

下载地址

 如果虚拟机网络可以到底互联网,可以使用下载。

wget https://github.com/goharbor/harbor/releases/download/v2.8.3/harbor-offline-installer-v2.8.3.tgz
[root@localhost harbor]# ls
harbor-offline-installer-v2.8.3.tgz
[root@localhost harbor]# pwd
/root/harbor
[root@localhost harbor]# mkdir /opt/install
[root@localhost harbor]# tar -xzf harbor-offline-installer-v2.8.3.tgz -C /opt/install

修改Harbor的配置

[root@localhost harbor]# cd /opt/install/harbor
[root@localhost harbor]# ls
common.sh  harbor.v2.8.3.tar.gz  harbor.yml  harbor.yml.tmpl  input  install.sh  LICENSE  prepare
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml

[root@localhost harbor]# cat harbor.yml
# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.56.100

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 85
# https related config
https:
  # https port for harbor, default is 443
#  port: 443
## The path of cert and key files for nginx
#  certificate: /your/certificate/path
#  private_key: /your/private/key/path

安装Harbor

[root@localhost harbor]# ./prepare
prepare base dir is set to /opt/install/harbor
Unable to find image 'goharbor/prepare:v2.8.3' locally
v2.8.3: Pulling from goharbor/prepare
64766fbe86f3: Pull complete 
5e8573822658: Pull complete 
b325f953ccaa: Pull complete 
4a61406f052d: Pull complete 
35af786c7219: Pull complete 
9e054aa5e0c4: Pull complete 
ac0b5dc3429a: Pull complete 
c1fcbc663df3: Pull complete 
35ef2e38ddee: Pull complete 
2a411a6b181f: Pull complete 
Digest: sha256:31b05f630675290977311f476bafba9406539c73aaa773f27fbe8a295cda184a
Status: Downloaded newer image for goharbor/prepare:v2.8.3
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[root@localhost harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 23.0.2

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.20.2

[Step 2]: loading Harbor images ...
176a9faee2d2: Loading layer [==================================================>]  6.176MB/6.176MB
7533b07674a0: Loading layer [==================================================>]  4.096kB/4.096kB
9ab27df52911: Loading layer [==================================================>]  3.072kB/3.072kB
457b8a810324: Loading layer [==================================================>]  17.57MB/17.57MB
8ade677a8a4b: Loading layer [==================================================>]  18.36MB/18.36MB
Loaded image: goharbor/registry-photon:v2.8.3
ae6af9dcdf7c: Loading layer [==================================================>]  6.171MB/6.171MB
d9b2d282124e: Loading layer [==================================================>]  9.098MB/9.098MB
71d01ecf12a5: Loading layer [==================================================>]  15.88MB/15.88MB
a93bf4c4de26: Loading layer [==================================================>]  29.29MB/29.29MB
d6ccdcf712be: Loading layer [==================================================>]  22.02kB/22.02kB
20d0340657f4: Loading layer [==================================================>]  15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.8.3
7076e9de5fb2: Loading layer [==================================================>]  6.171MB/6.171MB
06edddd4eeea: Loading layer [==================================================>]  9.098MB/9.098MB
4c8df5f33db0: Loading layer [==================================================>]  14.47MB/14.47MB
7bf292abe752: Loading layer [==================================================>]  29.29MB/29.29MB
ac4de38627ae: Loading layer [==================================================>]  22.02kB/22.02kB
687c00954816: Loading layer [==================================================>]  14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.8.3
ab5bc430313c: Loading layer [==================================================>]  90.16MB/90.16MB
dc3ba398e48c: Loading layer [==================================================>]  3.584kB/3.584kB
d26b379ad813: Loading layer [==================================================>]  3.072kB/3.072kB
93e3e2322706: Loading layer [==================================================>]   2.56kB/2.56kB
0bf9c54793f1: Loading layer [==================================================>]  3.072kB/3.072kB
2742f8f52b00: Loading layer [==================================================>]  3.584kB/3.584kB
299dda8831bd: Loading layer [==================================================>]  20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.8.3
02ddc8ed9baf: Loading layer [==================================================>]   85.6MB/85.6MB
377838d34c47: Loading layer [==================================================>]  3.072kB/3.072kB
1bda8bcd6461: Loading layer [==================================================>]   59.9kB/59.9kB
90ea325b2c6d: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.8.3
3996ab5000eb: Loading layer [==================================================>]  9.188MB/9.188MB
03553e550818: Loading layer [==================================================>]  3.584kB/3.584kB
9f2717a623b0: Loading layer [==================================================>]   2.56kB/2.56kB
ce715e5a53cf: Loading layer [==================================================>]  47.46MB/47.46MB
9505353423e5: Loading layer [==================================================>]  48.25MB/48.25MB
Loaded image: goharbor/harbor-jobservice:v2.8.3
Loaded image: goharbor/prepare:v2.8.3
b99dc282b3c7: Loading layer [==================================================>]  9.188MB/9.188MB
786372442d5c: Loading layer [==================================================>]  3.584kB/3.584kB
c95eff9c3c92: Loading layer [==================================================>]   2.56kB/2.56kB
69a6620f70fd: Loading layer [==================================================>]  59.22MB/59.22MB
faee135ed65a: Loading layer [==================================================>]  5.632kB/5.632kB
b8228ebe38a4: Loading layer [==================================================>]  116.7kB/116.7kB
e2db669e8a7c: Loading layer [==================================================>]  44.03kB/44.03kB
1d973fccb394: Loading layer [==================================================>]  60.17MB/60.17MB
747dd0c43ef1: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.8.3
1122996461e4: Loading layer [==================================================>]  6.176MB/6.176MB
c11d210da0c1: Loading layer [==================================================>]  4.096kB/4.096kB
7abff3111e9b: Loading layer [==================================================>]  17.57MB/17.57MB
569fe4e2f2c9: Loading layer [==================================================>]  3.072kB/3.072kB
bca259d7c630: Loading layer [==================================================>]  31.01MB/31.01MB
2dda2be83cfd: Loading layer [==================================================>]  49.37MB/49.37MB
Loaded image: goharbor/harbor-registryctl:v2.8.3
825a82984415: Loading layer [==================================================>]  82.12MB/82.12MB
Loaded image: goharbor/nginx-photon:v2.8.3
39074d649f8c: Loading layer [==================================================>]  6.707MB/6.707MB
688b64470d74: Loading layer [==================================================>]  4.096kB/4.096kB
320f85b1e3eb: Loading layer [==================================================>]  3.072kB/3.072kB
dde1dfb74607: Loading layer [==================================================>]  194.8MB/194.8MB
229337a9e8cc: Loading layer [==================================================>]   14.1MB/14.1MB
8c74af69019d: Loading layer [==================================================>]  209.7MB/209.7MB
Loaded image: goharbor/trivy-adapter-photon:v2.8.3
74b07281d2e5: Loading layer [==================================================>]  82.12MB/82.12MB
751e146c3c0f: Loading layer [==================================================>]    6.1MB/6.1MB
2cbfa90aca6d: Loading layer [==================================================>]  1.233MB/1.233MB
Loaded image: goharbor/harbor-portal:v2.8.3
3a8f210ea3e0: Loading layer [==================================================>]  116.2MB/116.2MB
06434a1eae73: Loading layer [==================================================>]  25.18MB/25.18MB
0923361e26b9: Loading layer [==================================================>]   5.12kB/5.12kB
e4658596b9ef: Loading layer [==================================================>]  6.144kB/6.144kB
350bc2e11862: Loading layer [==================================================>]  3.072kB/3.072kB
54847be3f348: Loading layer [==================================================>]  2.048kB/2.048kB
67296b765de0: Loading layer [==================================================>]   2.56kB/2.56kB
136c1f931ee8: Loading layer [==================================================>]   2.56kB/2.56kB
c44a36e8102e: Loading layer [==================================================>]   2.56kB/2.56kB
60bcea6b0ccb: Loading layer [==================================================>]  9.728kB/9.728kB
Loaded image: goharbor/harbor-db:v2.8.3
85c2b8de0e50: Loading layer [==================================================>]  9.188MB/9.188MB
1fd29ea96459: Loading layer [==================================================>]  26.04MB/26.04MB
9154b665386d: Loading layer [==================================================>]  4.608kB/4.608kB
9e173c1e037d: Loading layer [==================================================>]  26.83MB/26.83MB
Loaded image: goharbor/harbor-exporter:v2.8.3


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/install/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                                                                                                    0.0s 
 ✔ Container harbor-log         Started                                                                                                                                                                    0.4s 
 ✔ Container harbor-portal      Started                                                                                                                                                                    1.1s 
 ✔ Container registryctl        Started                                                                                                                                                                    1.1s 
 ✔ Container redis              Started                                                                                                                                                                    0.9s 
 ✔ Container registry           Started                                                                                                                                                                    0.9s 
 ✔ Container harbor-db          Started                                                                                                                                                                    1.0s 
 ✔ Container harbor-core        Started                                                                                                                                                                    1.3s 
 ✔ Container harbor-jobservice  Started                                                                                                                                                                    1.6s 
 ✔ Container nginx              Started                                                                                                                                                                    1.6s 
✔ ----Harbor has been installed and started successfully.----

查看docker compose状态:

[root@localhost harbor]# docker compose ls
NAME                STATUS              CONFIG FILES
harbor              running(9)          /opt/install/harbor/docker-compose.yml

常用启动停止命令

--启动
docker compose -f /opt/install/harbor/harbor.yml up -d
--停止
docker compose -f /opt/install/harbor/harbor.yml stop
--重启
docker compose -f /opt/install/harbor/harbor.yml restart

创建Harbor用户和项目

http://192.168.56.100:85/

 创建项目:tensquare

创建用户:XXXX 密码:XXXX

 项目分配用户:

 

选择对应的角色:

角色权限说明
访客对于指定项目拥有只读权限
开发人员对于指定项目拥有读写权限
维护人员对于指定项目拥有读写权限,创建 Webhooks
项目管理员除了读写权限,同时拥有用户管理/镜像扫描等管理权限

把镜像上传到Harbor

下面演示将192.168.56.100机器上的镜像webapp001上传到位于192.168.56.100机器上的Harbor。

在production-server机器上完成下面步骤:

(1) 把Harbor地址加入到Docker信任列表
# vim /etc/docker/daemon.json
{
    "registry-mirrors":[
        "https://zydiol88.mirror.aliyuncs.com"
    ],
    "insecure-registries":[
        "192.168.56.100:85"
    ]
}

(2) 重启docker
systemctl restart docker

(3) 登录Harbor
[root@localhost harbor]# docker login -u 用户名 -p 密码 192.168.56.100:85
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

(4) 给需要上传到Harbor的镜像打标签
docker tag webapp001:V1 192.168.56.100:85/tensquare/webapp001:v1.0

(5) 推送镜像到Harbor
[root@localhost ~]# docker push 192.168.56.100:85/tensquare/webapp001:v1.0
The push refers to repository [192.168.56.100:85/tensquare/webapp001]
f732db36266b: Pushed 
ceaf9e1ebef5: Pushed 
9b9b7f3d56a0: Pushed 
f1b5933fe4b5: Pushed 
v1.0: digest: sha256:e29e461e556f9cae489d8af98380799497f7fe31089d9a9df051fcc3a6f3e9ae size: 1159

[root@localhost ~]# docker images
REPOSITORY                              TAG       IMAGE ID       CREATED         SIZE
192.168.56.100:85/tensquare/webapp001   v1.0      d0b3485e2db7   3 months ago    122MB
webapp001                               V1        d0b3485e2db7   3 months ago    122MB
webapp001                               latest    d0b3485e2db7   3 months ago    122MB
xlrl/mantisbt                           latest    95dc52690259   3 months ago    571MB
jenkinsci/blueocean                     latest    04540a0bb985   10 months ago   579MB
fjudith/draw.io                         latest    7905aa0f7047   2 years ago     684MB

从Harbor下载镜像

在需要从Harbor上拉取镜像的机器需要完成如下步骤

(1) 安装Docker,并启动Docker

(2) 把Harbor地址加入到Docker信任列表
# vim /etc/docker/daemon.json
{
    "registry-mirrors":[
        "https://zydiol88.mirror.aliyuncs.com"
    ],
    "insecure-registries":[
        "192.168.56.100:85"
    ]
}

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

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

相关文章

第四章:Spring上

第四章:Spring上 4.1:Spring简介 Spring概述 官网地址:https://spring.io/。 Spring是最受欢迎的企业级的java应用程序开发框架,数以百万的来自世界各地的开发人员使用Spring框架来创建性能好、易于测试、可重用的代码。Spring框…

【多模态】18、ViLD | 通过对视觉和语言知识蒸馏来实现开集目标检测(ICLR2022)

文章目录 一、背景二、方法2.1 对新类别的定位 Localization2.2 使用 cropped regions 进行开放词汇检测2.3 ViLD 三、效果 论文:Open-vocabulary Object Detection via Vision and Language Knowledge Distillation 代码:https://github.com/tensorflo…

Verilog语法学习——LV10_使用函数实现数据大小端转换

LV10_使用函数实现数据大小端转换 题目来源于牛客网 [牛客网在线编程_Verilog篇_Verilog快速入门 (nowcoder.com)](https://www.nowcoder.com/exam/oj?page1&tabVerilog篇&topicId301) 题目 描述 在数字芯片设计中,经常把实现特定功能的模块编写成函数&…

HBuilder 编辑器终端窗口无法输入,未响应的解决方案

HBuilder 编辑器终端窗口无法输入,未响应的解决方案 一、找到 HBuilder 安装目录 找到 main.js HBuilderX - plugins - builtincef3terminal - script - main.js 二、编辑 main.js 将 main.js 文件中的 powershell.exe 和 cmd.exe 路径都改为绝对路径 C:/Windows…

【渗透测试】漏洞扫描AWVS安装使用教程,三分钟手把手教会,非常简单

一、AWS简介 Acunetix Web Vulnerability Scanner(简称AWVS)是一个自动化的Web漏洞扫描工具,它可以扫描任何通过Web浏览器访问和遵循HITP/HTTPS规则的Web站点。 AWVS原理是基于漏洞匹配方法,通过网络爬虫测试你的网站安全,检测流行安全AWVS可…

Hadoop学习日记-YARN组件

YARN(Yet Another Resource Negotiator)作为一种新的Hadoop资源管理器,是另一种资源协调者。 YARN是一个通用的资源管理系统和调度平台,可为上层应用提供统一的资源管理和调度 YARN架构图 YARN3大组件: (物理层面&#xff09…

Spring学习笔记,包含Spring IOC、AOP基本原理、Bean管理、Spring 事务等等

😀😀😀创作不易,各位看官点赞收藏. 文章目录 Spring 基础笔记1、控制反转 (IOC)1.1、IOC 底层原理1.2、IOC 之Bean管理 ( XML )1.3、IOC 之Bean管理 (FactoryBean)1.4、Bean的作用域1.5、Bean的生命周期1.6、Bean的自动装配1.7、I…

SFP6002-ASEMI代理海矽美快恢复二极管参数、尺寸、规格

编辑:ll SFP6002-ASEMI代理海矽美快恢复二极管参数、尺寸、规格 型号:SFP6002 品牌:ASEMI 封装:TO-247AB 恢复时间:30ns 正向电流:60A 反向耐压:200V 芯片大小:102MIL*2 芯…

几个影响 cpu cache 性能因素及 cache 测试工具介绍

》内核新视界文章汇总《 文章目录 1 cache 性能及影响因素1.1 内存访问和性能比较1.2 cache line 对性能的影响1.3 L1 和 L2 缓存大小1.4 指令集并行性对 cache 性能的影响1.5 缓存关联性对 cache 的影响1.6 错误的 cacheline 共享 (缓存一致性)1.7 硬件设计 2 cpu cache benc…

【EI/SCOPUS会议征稿】第四届机器学习与计算机应用国际学术会议(ICMLCA 2023)

ICMLCA 2023 第四届机器学习与计算机应用国际学术会议 2023 4th International Conference on Machine Learning and Computer Application 第四届机器学习与计算机应用国际学术会议(ICMLCA 2023)定于2023年10月27-29日在中国杭州隆重举行。本届会议将主要关注机器学习和计算…

rk3568 Debian11 如何打开热点

思路:1. 下载必要工具(hostapt、dnsmasq)2. 配置网络(无线网卡配置静态IP)3. 配置hostapt配置文件4. 配置DHCP服务5. 启动服务(hostapd/dnsmasq/network)6. IP转发(这一步决定了是否…

【QT 网络云盘客户端】——登录界面功能的实现

目录 1.注册账号 2.服务器ip地址和端口号设置 3. 登录功能 4.读取配置文件 5.显示主界面 1.注册账号 1.点击注册页面,将数据 输入 到 用户名,昵称,密码,确认密码,手机,邮箱 的输入框中, 点…

Vue3 导出word

🙂博主:锅盖哒 🙂文章核心:导出word 目录 1.首先,你需要安装docxtemplater库。可以使用npm或yarn来安装: 2.在Vue组件中,你可以使用docxtemplater来生成Word文档并提供一个导出按钮供用户下载…

线性表之顺序表

在计算机科学中,数据结构是非常重要的基础知识之一。数据结构为我们提供了组织和管理数据的方法和技巧,使得我们可以高效地存储、检索和操作数据。而顺序表作为数据结构中最基本、最常用的一种存储结构,也是我们学习数据结构的第一步。 本文将…

idea 关于高亮显示与选中字符串相同的内容

dea 关于高亮显示与选中字符串相同的内容,本文作为个人备忘的同时也希望可以作为大家的参考。 依次修改File-settings-Editor-Color Scheme-General菜单下的Code-Identifier under caret和Identifier under caret(write)的Backgroud色值,可以参考下图。…

阿里云域名备案

最好的爱情,不是因为我们彼此需要在一起,而是因为我们彼此想要在一起。 阿里云的域名如何备案,域名备案和ICP备案一样吗?? 截至我所掌握的知识(2021年9月),阿里云的域名备案和ICP备案…

【GoLang】基础语法(上)

Go基础语法(上) 文章目录 Go基础语法(上)01注释02变量定义初始化打印内存地址变量交换匿名变量变量的作用域 03常量iota 04基本数据类型布尔类型数字类型整型浮点型 字符与字符串 05数据类型转换06运算符算术运算符关系运算符逻辑运算符位运算符赋值运算符 07获取键盘输入 01注…

Java 设计模式 - 简单工厂模式 - 创建对象的简便之道

简单工厂模式是一种创建型设计模式,它提供了一种简单的方式来创建对象,而无需暴露对象创建的逻辑。在本篇博客中,我们将深入了解简单工厂模式的概念、实现方式以及如何在Java中使用它来创建对象。 为什么使用简单工厂模式? 在软…

PC音频框架学习

1.整体链路 下行播放: App下发音源→CPU Audio Engine 信号处理→DSP数字信号处理→Codec DAC→PA→SPK 上行录音: MIC拾音→集成运放→Codec ADC→DSP数字信号处理→CPU Audio Engine 信号处理→App 2.硬件 CPU PCH DSP(可选) Codec PA SPKbox MIC…

Vue 3 中的插槽(Slots)用法

插槽&#xff08;Slots&#xff09;是 Vue 组件中一种非常有用的功能&#xff0c;用于在父组件中向子组件传递内容。Vue 3 引入了 <script setup> 语法&#xff0c;使得组件的写法更加简洁和易读。在本篇博客中&#xff0c;我们将探讨在 Vue 3 中使用插槽的不同方式&…