redux的dispatch()中的[[Scopes]]是什么 [英] What is [[Scopes]] in dispatch() of redux

查看:170
本文介绍了redux的dispatch()中的[[Scopes]]是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用redux做出反应。这使得调度可用作组件中的道具。所以当我 console.log(this.props)时,我会在日志下的dispatch键中看到以下对象。

I am using redux with react. This makes dispatch available as props in component. So when I console.log(this.props) I see following object in log under dispatch key.

[[Scopes]]: Scopes[5]
   0:Closure
   1:Closure
   2:Closure (createThunkMiddleware)
   3:Closure
   4:Global

有人可以解释这是什么?

Can someone explain what is this ?

推荐答案

[[Scopes]] 是Chrome开发人员的私有财产工具在内部添加和使用,在C ++中,此处来源。它显示函数范围内的变量,即可以从该函数访问哪些变量。

[[Scopes]] is a private property that Chrome developer tools add and use internally, in C++, here in the source. It displays the variables that are in the scope of a function, i.e. which variables can be accessed from that function.

例如:

function a() {
  var foo = 'foo';
  var obj = {
    bar: function () {
      return foo;
    }
  };
  console.log(obj);
}
a();

这里,附加到属性的函数 obj.bar 在其范围内有变量 foo ,所以当我们检查 [[Scopes]] obj.bar 我们看到类似

Here, the function that is attached to property obj.bar has variable foo in its scope, so when we inspect the [[Scopes]] propety of obj.bar we see something like

[[Scopes]]: Scopes[2]
0: Closure (a)
  foo: "foo"
1: Global
  (all global variables)






您可以在控制台中手动检查这些属性,这可能有助于调试,但您不能使用JavaScript访问它们,您不应该在应用程序代码中关注它们。


You can manually inspect these properties in the console, which might be helpful for debugging, but you can't access them using JavaScript and you shouldn't care about them in your application code.

另请参阅: SO - 以编程方式访问功能位置

这篇关于redux的dispatch()中的[[Scopes]]是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆