![](/img/trans.png)
[英]JXCore Cordova => Native Cordova Plugin (can't reach cordova.exec(…))
[英]JXcore_cordova plugin nodejs android issue
使用express 4.12.3和cordova 5.0.0,以及jxcore-cordova插件 :
编写此简单的代码段不起作用:
var http = require('http');
var express = require('express');
var app = express();
var server = http.createServer(app);
server.listen(1337);
app.get('/',function(req,res){
res.sendFile(__dirname + '/public/index.html');
res.end();
});
返回错误是:
5611-5648 / com.example.hello E / jxcore-log:etag@/data/data/com.example.hello/files/node_modules/express/node_modules/etag/index.js:55:1 setHeader @ / data /数据/com.example.hello/文件/node_modules/express/node_modules/send/index.js:739:15 SendStream.prototype.send@/data/data/com.example.hello/files/node_modules/express/node_modules/ send / index.js:507:3 onstat@/data/data/com.example.hello/files/node_modules/express/node_modules/send/index.js:600:5 makeCallback / <@ fs.js:83:12 fs.stat@fs.js:718:7 sendFile@/data/data/com.example.hello/files/node_modules/express/node_modules/send/index.js:590:3 SendStream.prototype.pipe@/data/ data / com.example.hello / files / node_modules / express / node_modules / send / index.js:479:3 sendfile@/data/data/com.example.hello/files/node_modules/express/lib/response.js: 1029:3 sendFile@/data/data/com.example.hello/files/node_modules/express/lib/response.js:402:3 @ / data / data / com.example.hello / files / app.js:24 :5 handle@/data/data/com.example.hello/files/node_modules/express/lib/ro uter / layer.js:82:5 next@/data/data/com.example.hello/files/node_mod
但是,此代码可以正常工作:使用fs模块:
fs.readFile(__dirname + '/public/index.html',function(err,html){
app.get('/',function(req,res){
res.write(html);
res.end();
});
});
在Android Studio上进行了测试,并在Linux Mint和Windows 7上进行了eclipse测试。该插件在iOS上运行良好。
尝试不使用res.end
:
app.get('/',function(req,res){
res.sendFile(__dirname + '/public/index.html');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.