外部 paperscript 文件根本没有加载到我的 html 文件中
我正在尝试为 paper.js 制作一个基本测试程序,我打算将其用于项目。 我正在使用 chrome 来运行 HTML,当我打开开发工具时,chrome 似乎根本不加载我的脚本之一。我的文件结构是:
Test
|---mario.svg
|---html.html
|---scripts/
| |---script.js
| |---paper-core.js
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="./scripts/paper-full.min.js"></script>
<script type="text/paperscript" src="./scripts/script.js" canvas="myCanvas"></script>
</head>
<body>
<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
</canvas>
</body>
</html>
veiw.onFrame = function(event){
project.importSVG('.../mario.svg');
};
但是,在 chrome 开发工具中,在源代码下,我希望看到与我的文件结构相匹配的内容,而且我确实这样做了,只是缺少 script.js。 它还给了我这个错误: 从源“null”访问“file:///C:/Users/jacob/Documents/JS/Testing/scripts/script.js”处的 XMLHttpRequest 已被 CORS 策略阻止:仅协议方案支持跨源请求:http、数据、chrome、chrome-extension、chrome-untrusted、https。 ht @ paper-full.min.js:32
我认为这一定与文本/paperscript 有关,但我真的不知道,也绝对不知道如何解决它。我查看了示例,但无法弄清楚我在做什么不同的事情。 mario.svg 也没有显示,但我认为这只是因为 html 中没有引用它。有人可以解释一下吗?
I am trying to make a basic test program for paper.js, which I intend to use for a project.
I am using chrome to run the HTML and when I open the dev tools chrome seems to simply not load one of my scripts. My file structure is:
Test
|---mario.svg
|---html.html
|---scripts/
| |---script.js
| |---paper-core.js
And here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="./scripts/paper-full.min.js"></script>
<script type="text/paperscript" src="./scripts/script.js" canvas="myCanvas"></script>
</head>
<body>
<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #d3d3d3;">
</canvas>
</body>
</html>
veiw.onFrame = function(event){
project.importSVG('.../mario.svg');
};
In the chrome dev tools however, under sources, I would expect to see something that matches my file structure, and I do, except script.js is missing.
Also it gives me this error:
Access to XMLHttpRequest at 'file:///C:/Users/jacob/Documents/JS/Testing/scripts/script.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
ht @ paper-full.min.js:32
I think it must be something to do with the text/paperscript, but I really don't know and definately don't know how to fix it. I've looked at examples and can't figure out what I am doing differently. The mario.svg doesn't show up either but I think that's just because its not referenced in the html. Can someone explain this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
乍一看,我会说你的 PaperScript 代码没有运行,因为你加载了错误版本的 Paper.js。
您正在加载
paper-core.js
,这是不支持 PaperScript 的 Paper.js 版本。您应该改为加载paper-full.js
。At first sight, I would say that your PaperScript code is not run because you load the wrong version of Paper.js.
You are loading
paper-core.js
which is the version of Paper.js that does not support PaperScript. You should loadpaper-full.js
instead.