我在中编写了一些简单的js函数对象.js文件,但我无法用python脚本访问它们
当我将所有代码从文件粘贴到索引.html,一切正常
如何从文件执行函数对象.js? 在
在索引.html公司名称:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<link rel="stylesheet" href="doc/doc_brython.css">
</head>
<body onload="brython({debug:1, cache:'none'})">
<canvas id="spriteCanvas" width="640" height="480" style="border:1px solid #FF8844"></canvas>
<script type="text/javascript" src="objects.js"></script>
<script type="text/javascript" src="src/brython.js"></script>
<script type="text/python">
from browser import window
from browser import document as doc
pyjs=window
pyjs.create("instance",256,128);
pyjs.create("instance",256,256);
pyjs.create("player",128,256);
</script>
</body>
</html>
在对象.js公司名称:
^{pr2}$
代码失败,因为变量
instances
未在中声明对象.js. 在你想做什么并不明显
pyjs.create("instance",256,128)
在对象.js,
create
只接受一个参数。如果要将构造函数instance
创建的对象传递给对象.js,可以在Brython代码中使用以下语法:pyjs.create(pyjs.instance.new(256, 128));
函数“create”在本地js作用域中创建。试着
并在定义后可用
^{pr2}$相关问题 更多 >
编程相关推荐