企业网站作业01:渲染后台首页

原创 2018-11-21 11:10:42 169
摘要:第一步:public/admin.php第二步:application/admin/controller/index.php<?php namespace app\admin\controller; use think\Controller; use think\facade\View; class Index extends C

第一步:public/admin.php

第二步:application/admin/controller/index.php

<?php
namespace app\admin\controller;
use think\Controller;
use think\facade\View;

class Index extends Controller
{
    public function index()
    {
       return $this->view->fetch();
    }
    
    public function welcome(){
    	return $this->view->fetch();
    }

  
}

3.application/admin/view/index/index.html

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>PHP中文网后台管理系统</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__STATIC__/css/font.css">
<link rel="stylesheet" href="__STATIC__/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="__STATIC__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/js/xadmin.js"></script>

config/template.php

return [
    // 模板引擎类型 支持 php think 支持扩展
    'type'         => 'Think',
    // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
    'auto_rule'    => 1,
    // 模板路径
    'view_path'    => '',
    // 模板后缀
    'view_suffix'  => 'html',
    // 模板文件名分隔符
    'view_depr'    => DIRECTORY_SEPARATOR,
    // 模板引擎普通标签开始标记
    'tpl_begin'    => '{',
    // 模板引擎普通标签结束标记
    'tpl_end'      => '}',
    // 标签库标签开始标记
    'taglib_begin' => '{',
    // 标签库标签结束标记
    'taglib_end'   => '}',
    'tpl_replace_string'  =>  [
    '__STATIC__'=>'/static/admin',
	//'__JS__' => '/static/javascript',
]
];

总结:

  1. public下建立admin.php为后台入口文件

  2. 在app下建立admin文件夹,分别为controller 和view

  3. 配置config/template.php  '__STATIC__'=>'/static/admin', 即前台index.html使用__STATIC__

<iframe src='{:url("welcome")}' frameborder="0" scrolling="yes" class="x-iframe"></iframe>

批改老师:韦小宝批改时间:2018-11-21 13:40:15
老师总结:写的很不错!很完整!总结的也很到位!继续加油吧!

发布手记

热门词条