🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 页面渲染 在路由章节中我们学会了如何输出一个 hello world,但是在开发项目的时候,总不能只有那么几个字吧。 ## 渲染html 渲染一个页面: ~~~ \Lytpl\Lytpl::render_tpl('index.html',[ 'name' => '小卓', 'age' => 14, 'sex' => '男' ]); ~~~ 第一个参数代表着要渲染的页面名,第二个参数上需要在页面中使用的变量。"index.html"文件存放在:/app/view/public/下 一个完整的例子: ~~~ //index.php $lolly->route('/','indx'); function index(){ return \Lytpl\Lytpl::render_tpl('index.html',[ 'name' => '小卓', 'age' => 14, 'sex' => '男' ]); } //index.html <html> <head> <title>测试页面</title> </head> <body> <p>我的名字:{{$name}}</p> <p>我的年龄:{{$age}}</p> <p>我的性别:{{$sex}}</p> </body> </html> ~~~