视图 taro Posted on Apr 4 2021 Golang iris # 配置 main.go ```go tmpl := iris.HTML("./web/views", ".html"). Layout("shared/layout.html"). Reload(true) app.RegisterView(tmpl) app.HandleDir("/public", "./web/public") ``` layout.html ```html <html> <head> <title>{{.Title}}</title> </head> {{ yield }} </html> ``` login.html ```html ``` 当控制器中这样返回时,会自动将login.html中的代码装填到`yield`中 ```go var loginStaticView = mvc.View{ Name: "user/login.html", Data: iris.Map{"Title": "User Login"}, } ``` # 静态文件 ```go app.HandleDir("/public", "./web/public") ``` 控制器 Windows MSF Persistence