我正在查看Processing.js快速入门示例:http://processingjs.org/articles/jsQuickStart.html,并尝试复制这个“简单”示例:
<!DOCTYPE html>
<html>
<head>
<title>Hello Web - Processing.js Test</title>
<script src="https://cdn.rawgit.com/processing-js/processing-js/v1.4.8/processing.js"></script>
</head>
<body>
<h1>Processing.js Test</h1>
<p>This is my first Processing.js web-based sketch:</p>
<canvas data-processing-sources="hello.pde"></canvas>
</body>
</html>这是我的hello.pde文件的样子:
void setup() {
size(200, 200);
background(100);
stroke(255);
ellipse(50, 50, 25, 25);
println("hello web!");
}此外,我已经将我的文件.pde和.html文件都放到了我的MAMP服务器中,并通过localhost:http://localhost:8888/testprocessing.html访问它们
但是画布上什么也没有显示,并且我在控制台中得到了这个错误:processing.js:799 Uncaught SyntaxError: Unexpected string。下面是799行processing.js中的代码:
function loadBlock(index, filename) {
function callback(block, error) {
code[index] = block;
++loaded;
if (error) {
errors.push(filename + " ==> " + error);
}
if (loaded === sourcesCount) {
if (errors.length === 0) {
try {
return new Processing(canvas, code.join("\n"));
} catch(e) {
console.log("Processing.js: Unable to execute pjs sketch.");
throw e; //this is line 799
}
} else {
throw "Processing.js: Unable to load pjs sketch files: " + errors.join("\n");
}
}
}我是javascript的新手,错误来自processing.js文件,而不是我的代码,有人能解释一下吗?谢谢!
发布于 2016-06-08 00:15:22
您需要使用当前使用的库的全名重写处理库的路径。
例如,如果使用版本1.4.8,则必须这样写://./././processing-1.4.8.js
https://stackoverflow.com/questions/33862646
复制相似问题