模組:Static/doc
出自星砂島百科
更多語言
更多操作
此頁面為 模块: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')使用。