尝试索引局部变量 'ttlobj' (空值)

p .  pginfo = function ( frame )
     local title = tostring(frame.args.title) or ""
     local ttlobj = mw.title.new( title )
     local txt = ttlobj.text
     if ttlobj.exists then
       if ttlobj .isRedirect then
         txt = txt .. " 存在并且是一个重定向"
       else
         txt = txt .. " 存在并且不是重定向"
       end
     else
       txt = txt .. " 不存在"
     end
     return txt
end

{{#invoke:Sandbox/Shreyansh Saboo|pginfo|title=}} 我正在遇到错误,我该如何解决? 请帮助我。

点赞