模块:Static
来自星砂岛百科
更多操作
概述
Static 返回一个页面级共享表,用于在同一页面内的多次 #invoke 或 require 调用之间共享静态状态。
用法
local static = require('Module:Static')
static.Example = static.Example or {}
static.Example.count = (static.Example.count or 0) + 1
return static.Example.count
示例
local static = require('Module:Static')
static._global = static._global or {}
static._global.sample = 'ok'
return static._global.sample
注意事项
- 默认应在各模块自己的子表下保存状态,避免互相污染。
- 只有明确需要跨模块共享时,才使用
_global这样的公共命名空间。 - 该模块本身不提供
#invoke入口,建议通过require('Module:Static')使用。