我做了一些研究,找不到任何让我的案子成功的东西.
所以,我.js从外部脚本加载require(..),每个脚本导出一个函数..
main.js
var main=10;
var mod1 = require("./mod1.js");
Run Code Online (Sandbox Code Playgroud)
mod1.js
module.exports=function(){
console.log('loaded');
var net=require('net'); // i don't want it to be able to require certain node.js apis
net.create...;
}
Run Code Online (Sandbox Code Playgroud)
我看到了.json文件声明的一些方法,permissions如果是这样,它会授予对脚本的访问权限.如何在核心node.js apis中实现类似的功能?
我最近尝试一起工作快,我觉得那种困难,我试图定义在路由app.js文件后require,以index.js我仍然得到这个错误,当我尝试浏览localhost:3000/route
该query.js文件
exports.show = function(reg,res){
res.render("test",{title:"query testing"});
};
Run Code Online (Sandbox Code Playgroud)
我试过这个 app.js
app.get('/query',require('./routes/query.js'));
Run Code Online (Sandbox Code Playgroud)
并在 index.js
var queryX = require('./query.js');
app.get('/query',queryX.show);
Run Code Online (Sandbox Code Playgroud)
我route-separation在github上尝试了这个例子,我也得到了一个错误,
为什么我不能让这个工作?
我最近进入了nativescript,我遇到了一个我似乎无法解决的问题.
我想要完成的只是打开一个基本的WebView并设置一个外部URL来加载,如stackoverflow.com.
我在Android api 17的模拟器上运行它
app.js
var application = require("application");
application.mainModule = "main-page";
application.cssFile = "./app.css";
application.start();
Run Code Online (Sandbox Code Playgroud)
主page.js
var vmModule = require("./main-view-model");
var webViewModule = require("ui/web-view");
var webView = new webViewModule.WebView();
function pageLoaded(args) {
var page = args.object;
var web = page.getViewById(webViewModule.WebView,"webView");
web.url="http://google.com";
}
exports.pageLoaded = pageLoaded;
Run Code Online (Sandbox Code Playgroud)
主page.xml
<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
<StackLayout>
<WebView id="webView" colSpan="4" row="2"/>
</StackLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)
我还检查了INTERNET权限是否设置为application,是的,启用了.
应用程序也停止工作,并且命令
tns运行android --emulator
在模拟器上成功安装并运行应用程序后,它只会发送大量输出.
你能帮助我理解究竟应该如何工作吗?