2017-10-16 111 views
0
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功能我得到这个错误时加载:使用url下载模块

File: module '<<path of the file>>.tmp.MyModule.lua' not found 

回答