lua調用不一樣lua文件中的函數

a.lua和b.lua在同一個目錄下ui

a.lua調用b.lua中的test方法,注意b中test的寫法 _M 和 a中調用方法:lua

b.lua spa

local _M = {}
function _M.test()
    ngx.say("hello test!")
end
return _M
.net

 

a.luarest

 local test = require("b")
if not test then
    ngx.say("Failed to require b!")
    return
end
test:test()
blog

/openresty/lualib/resty裏面的寫法可參考string

參考連接:https://my.oschina.net/chrisforbt/blog/492999 --------------------- 做者:PureMastiff 來源:CSDN 原文:https://blog.csdn.net/Lovegengxin/article/details/80585634 版權聲明:本文爲博主原創文章,轉載請附上博文連接!it

相關文章
相關標籤/搜索