我有一个在html标头中声明的全局变量,并希望从模块内的类引用它.如何防止编译器错误:
错误TS2095:找不到符号'selfGlobal'.
<html>
<head>
<script>
var selfGlobal = this;
var globalVariable = 1;
</script>
</head>
<body>
<script src="test.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在test.ts中
module Test{
export class TestClass {
private _privateVariable:any;
constructor() {
this._privateVariable = selfGlobal.globalVariable; // compile error throws here, but the code can run
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!火星
简而言之,我已经设置了一个带有基本控制器的无前端风帆项目,并使用loadtest命中它,内存不断增加,没有稳定的迹象.我已经读过以前的帖子,并禁用了grunt,session,socket,pubsub等.
建立:
Sails版本:v0.12.3
节点版本:v4.4.7
NPM版本:v2.15.8
复制:
创建新的风帆项目
sails new Project --no-frontend
Run Code Online (Sandbox Code Playgroud)
编辑.sailsrc:
{
"generators": {
"modules": {}
},
"hooks": {
"session": false,
"sockets": false,
"pubsub": false,
"grunt": false,
"i18n": false
}
}
Run Code Online (Sandbox Code Playgroud)
添加了controllers/TestController.js:
module.exports = {
hi: function (req, res) {
return res.send("Hi there!");
}
};
Run Code Online (Sandbox Code Playgroud)
运行负载测试:
var loadtest = require('loadtest');
var host = 'http://localhost:1337';
var options = {
url: host + '/test/hi',
requestsPerSecond: 50
};
loadtest.loadTest(options, function(error, result)
{
if (error)
{
return console.error('Got an error: %s', error);
} …Run Code Online (Sandbox Code Playgroud) 我正在构建一个ARC iphone应用程序,并即将集成addThis ios库.
我收到以下错误:
ld: duplicate symbol _OBJC_CLASS_$_Facebook in /Users/mars/Desktop/Pst/trunk/Pst/ThirdPartyLibs/FBConnect/FacebookSDK/FacebookSDK.framework/FacebookSDK(Facebook.o) and /Users/mars/Library/Developer/Xcode/DerivedData/Pst-bqmphjiqldalzsankfvxugsurcdj/Build/Intermediates/Pst.build/Debug-iphonesimulator/Pst.build/Objects-normal/i386/Facebook.o for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
我用我的编译资源进行了双重检查,只有1个facebook.m存在.
我还在这些库文件的编译器标志中加入了"-fno-objc-arc",因为它们是在没有ARC的情况下构建的
任何帮助将非常感激!!