安装think-view 模板引擎驱动
composer require topthink/think-view
视图类配置一般在 配置目录下 config/view.php 中配置文件中定义
可以直接使用 think\facade\View 操作视图
<?php namespace app\dongadmin\controller; use app\BaseController; use think\facade\Db; use think\facade\View; // 引入门面类 class Company extends BaseController { public function index() { // 渲染模板的2种方式 // 方式1 return view(); // 方式2 需要引用use think\facade\View; return View::fetch('index'); } }