注册时间
最后登录
新帖
使用vscode,autox.js插件编写代码,使用autox.js插件新建项目,main.js和runScript.js同目录,都写在main.js中可以正常执行
下面是代码:
- runScript.js
let cycle = {};
cycle.queryList = function (json) {
for (var i = 0; i < json.length; i++) {
var sonList = json[i];
if (sonList.childCount() == 0) {
console.log(json[i])
} else {
this.queryList(sonList);
}
}
}
//...
module.exports = cycle
main.js
let cycle = require("./runScript.js");
// ...
F5运行报错:
16:39:16.923/V: 开始运行[[remote]main.js]
16:39:17.034/E: Error: Can't resolve relative module ID "./runScript.js" when require() is used outside of a module (/android_asset/modules/jvm-npm.js#87)
Error: Can't resolve relative module ID "./runScript.js" when require() is used outside of a module
at Require (/android_asset/modules/jvm-npm.js:87:0)
at [remote]main.js:1:0