我正在尝试建立Cordova.当我运行时cordova build android
收到以下错误:
(node:6816) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to run "javac -version", make sure that you have a JDK installed.
You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.
Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_161;C:\Program Files\Java\jdk1.8.0_161\bin
Run Code Online (Sandbox Code Playgroud)
但是我可以运行javac -version
得很好.
C:\>javac -version
javac 1.8.0_161
Run Code Online (Sandbox Code Playgroud)
我试图以JAVA_HOME
各种方式设置:指向根; 指向bin
文件夹; 将其设置为User变量,也设置为System one; 添加%JAVA_HOME%\bin
到Path
(用户和系统)等等.
我已经检查了几篇关于这个问题的文章,并且他们说如果我能够使用javac -version
那么那应该表明我的环境变量设置正确.即使是这样,科尔多瓦似乎仍然没有认识到它.
遵循Stephen C的指示,我已经重置了我的变量,但我的错误仍然存在.正如你可以在图片中看到,我可以打电话javac
就好了,都JAVA_HOME
和Path
似乎以正确的方式进行设置.(注意,它实际上是,%JAVA_HOME%\bin
而不是C:\Program Files\Java\jdk1.8.0_161\bin
在Path
.)
我尝试在 Code::Blocks 中使用 MinGW 编译 Assimp,但出现以下错误。
\assimp-3.3.1\assimp-3.3.1\code\StringComparison.h||In function 'int Assimp::ASSIMP_stricmp(const char*, const char*)':|
\assimp-3.3.1\assimp-3.3.1\code\StringComparison.h|144|error: '::strcasecmp' has not been declared|
\assimp-3.3.1\assimp-3.3.1\code\StringComparison.h||In function 'int Assimp::ASSIMP_strincmp(const char*, const char*, unsigned int)':|
\assimp-3.3.1\assimp-3.3.1\code\StringComparison.h|193|error: '::strncasecmp' has not been declared|
Run Code Online (Sandbox Code Playgroud)
在搜索时,我发现有问题的两个函数(strcasecmp 和 strncasecmp)实际上是在其中声明的,string.h
该函数包含在StringComparison.h
. 我还设法获取了strings.h
它们最初所属的文件,但包括该文件也没有解决问题。
在搜索这个网站时,我发现我并不是唯一一个遇到这个问题的人。我发现的另一个解决方案建议使用定义语句,因为这些函数的名称可能略有不同,但这也没有帮助。
我在Node.js中有以下对象和lodash"查询"(我只是node
在终端中运行):
var obj = {
a: [{
b: [{
c: "apple"
},
{
d: "not apple"
},
{
c: "pineapple"
}]
}]
};
> _.get(obj, "a[0].b[0].c")
'apple'
> _.get(obj, "a[0].b[1].c")
undefined
> _.get(obj, "a[0].b[2].c")
'pineapple'
Run Code Online (Sandbox Code Playgroud)
我的问题是:有没有办法返回路径被发现有效的值数组?
例:
> _.get(obj, "a[].b[].c")
['apple', 'pineapple']
Run Code Online (Sandbox Code Playgroud) 我正在使用 JavaScript 加载图像。像这样的东西:
images[0]=new Image();
images[0].onload=function(){loaded++;console.log(loaded)};
images[0].src="assets/img/image.png";
Run Code Online (Sandbox Code Playgroud)
当我查看日志时,我看到所有图像都加载得很好,因为“加载”变量的值随着每个加载的图像而增加。
但是我想停止执行任何进一步的操作,直到这个数量达到最大值,所以在设置图像后,我放置了一个 while 循环。
while(loaded<11){
document.getElementById("test").innerHTML="Loading "+loaded+"/11";
console.log(loaded);
}
//Some code here which should only run after everything has been loaded
//In other words: when the statement in the while cycle becomes false
Run Code Online (Sandbox Code Playgroud)
然而,我的浏览器只是崩溃了,因为 while 似乎陷入了无限循环。当我查看日志时,我看到“0”被写入了 1000 次,然后是从 1 到 11 的数字(这意味着图像实际上已加载,但 while 并不关心它,并且崩溃得更快比它可能发生)。
我相信我在这里尝试使用的方法不是解决这个问题的正确方法。
在加载站点所需的每个资产之前,如何将所有内容搁置?
我正在尝试使用 JavaScript 在 Canvas 元素上制作淡出效果。我目前对此有两种解决方案。从理论上讲,两者都应该可以正常工作,但在实践中,只有一个可以,我想知道为什么。
不工作的代码如下:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var i = 1;
requestAnimationFrame(test);
function test(){
i-=0.01;
ctx.fillStyle = "white";
ctx.fillRect(20, 20, 75, 50);
ctx.globalAlpha = i;
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 75, 50);
requestAnimationFrame(test);
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的是逐渐改变当前上下文的 alpha 值,以便将其淡入白色。一段时间后,它应该具有完全透明度,但事实并非如此。它在到达该状态之前停止。这是 JSFiddle 中的: https: //jsfiddle.net/bq75v1mm/
工作代码如下:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var i = 1;
requestAnimationFrame(test);
function test(){
i-=0.01;
ctx.fillStyle = "white";
ctx.fillRect(20, 20, 75, 50);
ctx.fillStyle = "rgba("+255+","+0+","+0+","+i+")";
ctx.fillRect(20, 20, 75, 50);
requestAnimationFrame(test); …
Run Code Online (Sandbox Code Playgroud) 当我尝试编译类似于以下内容的东西时,我收到标题中提到的错误消息.
class Object{
public:
Object(){
//Something
}
void x(){
//Something
}
}
void function(std::vector<Object>* things){
int someNumber;
//Some algorithm to get the value of someNumber.
things->resize(someNumber);
for(int i=0;i<someNumber;i++){
things[i].x();
}
}
int main(){
vector<Object> things;
function(&things);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
什么可能导致麻烦?