跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

CURL

最后更新 查看 MarkdownAgent 设置

The CURL component is used 80 times on 30 pages.

See all examples of pages that use CURL

Used 80 times.

Pages

Partials

CURL 组件用于显示发起 HTTP 请求的 cURL 命令。

导入

import { CURL } from "~/components";

用法

import { CURL } from "~/components";

<CURL
	url="https://httpbin.org/anything"
	method="POST"
	json={{
		key: "va'l'ue",
	}}
	query={{
		foo: "bar",
		bar: ["baz", "qux"],
	}}
	code={{
		mark: "value",
	}}
/>

<CURL
	url="https://httpbin.org/anything"
	method="POST"
	form={{
		key: "value",
	}}
	code={{
		mark: "value",
	}}
/>

<CURL> 属性

url

必需

类型: string

发起请求的 URL。

method

类型: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "PATCH"

默认值: "GET"

请求要使用的 HTTP 方法。

headers

类型: Record<string, string>

请求中要包含的标头。

json

类型: Record<string, any> | Record<string, any>[]

请求中要包含的 JSON 数据。

form

类型: Record<string, any>

要发送的 FormData 负载。

query

类型: Record<string, string | string[]>

要附加到请求 URL 的 URL 查询参数。

code

类型: object

包含 Astro Code 属性的对象。有关可用属性,请参阅 Astro Code 组件文档 ↗。

这篇文档对您有帮助吗?