저는 AppJS/NodeJS와 edge를 사용하여 기본적인 데모 애플리케이션을 만들었습니다.AppJs 및 nodejs 내의 외부 모듈 사용
기본적으로 외부 모듈을 참조하기 만하면 app.js 구성 파일의 관련 부분을 확인합니다.
.......
window.on('ready', function(){
console.log("Window Ready");
window.process = process;
window.module = module;
window.dns = require('native-dns');
window.edge = require('edge');
window.fs = require('fs');
window.frame.openDevTools();
..........
그리고 heres는 주요 index.html을 페이지의 관련 자바 스크립트 부분 :
.......
function myFunction1()
{
var question = dns.Question({
name: 'www.google.com',
type: 'A'
});
var req = dns.Request({
question: question,
server: { address: '8.8.8.8', port: 53, type: 'udp' },
timeout: 1000
});
req.on('timeout', function() {
console.log('Timeout in making request');
});
req.on('message', function (err, answer) {
answer.answer.forEach(function (a) {
console.log(a.address);
});
});
req.on('end', function() {
console.log('Finished processing request');
});
req.send();
}
function myFunction2()
{
var helloWorld = edge.func('async (input) => { return ".NET Welcomes " + input.ToString(); }');
helloWorld('JavaScript', function (error, result) {
if (error) throw error;
console.log(result);
});
}
..........
내가 다른 nodejs 모듈 (DNS 조회)를 사용 myFunction1()를 호출하면이 완벽하게 작동합니다. 그러나 가장자리를 사용하는 myFunction2()를 호출하면 다음 오류가 발생합니다!
Uncaught TypeError: Property 'func' of object [object Object] is not a function
나는 이것에 몇 시간을 보냈다. 왜 그런 일이 일어나지 않았는가!
감사합니다. Simon - 저것 좀 봐주세요! – user1513388