03 2012 档案
摘要:modules 模块Node 使用 CommonJS 模块系统.var a = require('./b');var helloWorld = 'helloWorld';a.add(1,1);//2//b.jsexports.add = function(x , y){ return x + y;}exports.hello = function(){ console.log(helloWorld);}require('./b') 引用当前目录下的b.jsexports.add = function(){} 导出一个函数,这样require的时候
阅读全文
摘要:nodeJS的全局对象.可以直接调用不需要require的1 globals定义全局变量 exp: globals.hello = "helloWorld!"; 在node下就可以全部访问了, 一般在config配置文件使用;2 process进程对象 还没看的呢 先留的 慢慢学习3 require()引用模块4 require.resolve(str);查询模块路径 但是不引用,返回模块路径5 require.paths6 __filename获得当前文件的绝对路径7 __dirname获得当前文件目录的绝对路径8 module当前模块的引用
阅读全文
摘要:// Simple JavaScript Templating// John Resig - http://ejohn.org/ - MIT Licensed(function(){ var cache = {}; this.tmpl = function tmpl(str, data){ // Figure out if we're getting a template, or if we need to // load the template - and be sure to cache the result. var fn = !/\W/.test(str) ?...
阅读全文
浙公网安备 33010602011771号