我想獲取 beego 的app.conf 中定義的鍵的值并在 html 頁面中呈現。根據http://beego.me/docs/mvc/view/template.md 上的文檔,我可以通過在模板中使用配置函數來獲取 AppConfig 的值。但是文檔中沒有示例。獲取 AppConfig 的值。{{config configType configKey defaultValue}}。configType 必須是 String、Bool、Int、Int64、Float 或 DIY在嘗試了很多方法后,我得出了這個結論:<div>{{config config.String config.appname "TestDefaultValue"}}</div>但我總是收到錯誤:<config>: wrong number of args for config: want 3 got 0使用配置模板功能的正確方法是什么?
1 回答

躍然一笑
TA貢獻1826條經驗 獲得超6個贊
最后我自己解決了這個問題。config
模板函數接受所有參數作為字符串。
使用config
模板函數的正確方法是:
<div>{{config "String" "appname" "TestDefaultValue"}}</div>
- 1 回答
- 0 關注
- 210 瀏覽
添加回答
舉報
0/150
提交
取消