Controller 控制器的代码
<?php
namespace app\index\controller;
use think\Controller;
use think\facade\Route;
class Aa extends Controller{
public function aa(){
//传到页面的数据
$arr = [
["id" => 1,"name" => "王大帅"],
["id" => 2,"name" => "马德碧"],
["id" => 3,"name" => "蒋某啊"],
["id" => 4,"name" => "冰冰哥"],
];
//跳转渲染模版
return view("index@aa/aa",compact('arr'));
}
}
对应模版的代码aa.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>aaa</title>
</head>
<body>
<h1>蒋某帅帅帅</h1>
<ul>
{foreach $arr as $item}
<li>{$item.id}:{$item.name}</li>
{/foreach}
</ul>
<ul>
{volist id="item" name="arr"}
<li>{$item.id}:{$item.name}</li>
{/volist}
</ul>
年龄:{if $age < 10}儿童
{elseif $age <30 /}青年
{else /}中老年
{/if}
</body>
</html>
路由Route.php的代码
Route::get("aaa","index/aa/aa");
项目机构: