【发布时间】:2014-08-02 16:26:44
【问题描述】:
我一直在使用 Meteor 框架,我注意到在文档中有些函数被声明为 function(argument, [options]),这看起来不错。但是,其他人被声明为function([argument], [options])。如果参数是可选的,那不应该意味着它是一个选项吗?
例如,Meteor.absoluteUrl 在文档中定义如下:Meteor.absoluteUrl([path], [options])。 [path] 周围的括号表示不必传递,将使用默认值。但是,在它下面的部分中:
Generate an absolute URL pointing to the application. The server reads from the ROOT_URL environment variable to determine where it is running. This is taken care of automatically for apps deployed with meteor deploy, but must be provided when using meteor bundle. Arguments path String A path to append to the root URL. Do not include a leading "/". Options secure Boolean Create an HTTPS URL. replaceLocalhost Boolean Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name. rootUrl String Override the default ROOT_URL from the server environment. For example: "http://foo.example.com"
本质上,有人能解释一下参数、参数、选项和可选之间的区别吗?
【问题讨论】:
-
如果您想要我的支持,请在您的问题中包含一些代码或质量上下文;)
-
如果您提供来自 Meteor 的具体示例进行讨论/评论,这将更容易回答。
-
已编辑。 @SufiDeveloper,我一点也不关心赞成票。我想知道答案。
-
@RichLitt 没关系,如果你想得到答案,下次不要发垃圾问题。
-
@RichLitt 人们只是厌倦了低质量的问题。不了解某个主题并不意味着您不能提出优秀 问题,而这正是本网站的目的。这也不是我们必须互相牵手的地方。
标签: javascript function parameters meteor arguments