lua 文件相互调用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cn_yaojin/article/details/83383200

假设 demo1.lua 想调用 demo2.lua,那么需要在demo2.lua中如下设置:

local _M = {}

function _M.test1()
	return "hello world"
end

return _M

demo1.lua调用:

local demo = require("demo2")
demo.test1()

猜你喜欢

转载自blog.csdn.net/cn_yaojin/article/details/83383200
今日推荐