lua中通過require導(dǎo)入的文件,最終都存在package.loaded這個(gè)table中。
require會(huì)判斷是否文件已經(jīng)加載避免重復(fù)加載同一文件
所以需要先把package.loaded中對(duì)應(yīng)的內(nèi)容置空,然后再重新導(dǎo)入
local reTab = {}
for key,val in pairs(package.loaded) do
if string.sub(key,1,4) == "app/" or string.sub(key,1,4) == "app." or key == "config" then
if key ~= "app/views/LoginScene" then
package.loaded[key] = nil
reTab[#reTab + 1] = key
--print("key<<",key)
end
end
end