简体   繁体   English

如何使用Meteor.js浏览器Javascript控制台?

[英]How do I use Meteor.js browser Javascript Console?

Launching new Meteor.js project. 启动新的Meteor.js项目。 In client.js I put 在client.js中,我把

var hi = "widget";

    if (Meteor.isClient()){
    ...
    }

In my Browser's Console, and I type: 在浏览器的控制台中,输入:

>> hi
ReferenceError: hi is not defined
>> this.hi
undefined

It is probably locally scoped. 它可能在本地范围内。

Try: 尝试:

var global = Function("return this")();
global.hi = "widget";

Okay, this has changed just recently in version 0.6 and seems to be just a bug. 好的,这在0.6版本中已经发生了变化,似乎只是一个错误。 If you remove var at the declaration of hi, the scope of the variable will change and it will become accessible via JS console. 如果在hi的声明中删除var,则变量的范围将更改,并且可以通过JS控制台访问。 Still, it's a temporary situation, which will be likely be fixed in the future releases. 不过,这只是暂时的情况,在将来的版本中可能会修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM