在openwrt luci上工作。我有多个配置文件,例如:网络和无线在映射中面临问题。我使用以下语法进行映射
m = Map("network", translate("Wireless Settings"))
如何在一个模型中映射多个配置文件
最佳答案
要使用map(),首先我们需要清楚地了解 map 定义及其属性。这是 map 定义
class Map (config, title, description)
这是模型的根对象。
- config:要映射的配置名称,参见uci文档和 /etc/config 中的文件
- 标题:用户界面中显示的标题
- 描述:用户界面中显示的描述
您有两个配置网络和无线。好的,让我们开始多个配置文件绑定(bind)过程。首先我们映射网络配置文件,然后我们映射无线配置文件
使用网络配置文件进行映射
m = Map("network", translate("Wireless Settings")) -- We want to edit the uci config file /etc/config/network
m:chain("wireless")
s = m:section(NamedSection, "wan", "") -- Especially the "interface"-sections
注意: m:chain("config") 绑定(bind)第二个配置文件
带有无线配置文件的 map
m1 = Map("wireless","Wireless Network") -- We want to edit the uci config file /etc/config/network
s1 = m1:section(NamedSection,"wifi-iface", "") -- Especially the "interface"-sections
现在为了渲染,我们需要返回我的 map 模型对象
return m,m1
通过这种方式,您可以在一个模型中映射多个配置文件。
关于lua - 如何映射多个配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36032866/