【问题标题】:what does "[," mean in the syntax for describing input parameters format?“[”在描述输入参数格式的语法中是什么意思?
【发布时间】:2021-05-30 18:34:32
【问题描述】:

这是一个新手问题,但我找不到这种广泛用于描述输入参数格式的语法的名称/关键字。例如:

Request method aliases
For convenience aliases have been provided for all supported request methods.

axios.request(config)
axios.get(url[, config])
axios.delete(url[, config])
axios.head(url[, config])
axios.options(url[, config])
axios.post(url[, data[, config]])
axios.put(url[, data[, config]])
axios.patch(url[, data[, config]])

url[, config]url[, data[, config]] 的语法看起来很奇怪,而且不能自我解释。这种语法叫什么名字?

我看到它们被广泛使用,但不知道如何阅读它们。我只需要有人指出一个方向并告诉一个或两个关键字/名称。

【问题讨论】:

  • 这是一个可选参数,您可以但不需要提供。如果您不提供,则使用一些默认值(通常也在文档中描述)。

标签: syntax input-parameters


【解决方案1】:

在这里回答自己以防万一有人有同样的困惑:

[] 中的任何内容都是可选的。例如:

axios.get(url[, config])的表达式表示:

  1. axios.get(url) 是可以接受的,并且

  2. axios.get(url, config) 也可以。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    • 2016-10-17
    相关资源
    最近更新 更多