network.download( url, "GET", function(e)
if (e.isError == false) then
print("Download Successful")
-- get the path of the downloaded file
local path = system.pathForFile( "MyModule.lua" , system.TemporaryDirectory )
-- Replace "/" with "." because that's how "require" works
local newPath = string.gsub( path, "/", "." )
-- Load the module
local m = require ( newPath ) <<-- Error!
end
end, "MyModule.lua", system.TemporaryDirectory )
如您所见,我正在尝试从 url 下载模块。该文件确实被下载了,但是当尝试使用require
函数加载它时,我收到此错误:
File: module '<<path of the file>>.tmp.MyModule.lua' not found
看看这个话题 - https://forums.coronalabs.com/topic/27060-requiring-lua-file-from-documents-directory/
似乎您无法在真实设备上require
/loadstring
。