我正在探索 Paper.js 库。本教程中的第一个代码示例运行良好。但是,当我将内联 javascript 移动到外部文件时,就像在第二个代码片段中一样,它会停止在屏幕上显示任何内容。在 myScript.js 中,我尝试了
paper.install(window);
window.onload = function() {
// Create a Paper.js Path to draw a line into it:
var path = new Path();
// Give the stroke a color
path.strokeColor = 'black';
var start = new Point(100, 100);
// Move to start and draw a line from there
path.moveTo(start);
// Note the plus operator on Point objects.
// PaperScript does that for us, and much more!
path.lineTo(start + [ 100, -50 ]);
}
并使用 jQuery
$(document).ready(function(){
// Create a Paper.js Path to draw a line into it:
var path = new Path();
// Give the stroke a color
path.strokeColor = 'black';
var start = new Point(100, 100);
// Move to start and draw a line from there
path.moveTo(start);
// Note the plus operator on Point objects.
// PaperScript does that for us, and much more!
path.lineTo(start + [ 100, -50 ]);
});
没有成功。我忘记了什么?谢谢你的帮助