>当我尝试从另一个类调用其他类的方法时,它说错误消息:
Attempt to call field 'LoadShift' (a nil value)
这是我的代码,登录页面1.lua
local LoadShift = nil;
.
.
function LoadShift()
end
登录页面2.lua
local loginObj = require("com.classess.loginpage1")
loginObj.LoadShift();
我的代码有什么问题,请帮我解决这个问题
像这样制作你的自定义类
------------Your class LoadShift---------------
local LoadShift = {}
.
.
function LoadShift:LoadShiftFunc()
--do somthing
end
.
.
return LoadShift
-------------------------------------
然后需要它并调用该函数,例如
---------------------
local LoadShift= require "LoadShift"
LoadShift:LoadShiftFunc()