如何加载库?
我觉得问这样一个被认为是平凡的事情是很愚蠢的,但我在Ecma-262或MDN上找不到答案。
解决方案必须与d8 (V8)、jjs (Nashorn)、js (SpiderMonkey)、rhino (Rhino)、seed (JavaScriptCore)协同工作。
发布于 2014-08-20 18:49:06
if ('undefined' === typeof(require)) {
if ('function' === typeof(load)) {
require = load;
} else if ('object' === typeof(imports)) {
require = function(library_name) {
eval(imports.gi.Gio.file_new_for_path(
library_name).read().get_contents());
}
} else {
throw('require not implemented');
}
}
require('./some_library.js');
console.log(some_library.some_function(some_parameters));https://stackoverflow.com/questions/25205945
复制相似问题