1. 配置环境
- 配置减速源,装置orm扩大,装置composer,装置驱动,应用composer命令在指定的目录装置Thinkphp6.x;
配置conposer中国源composer config -g repo.packagist composer https://packagist.phpcomposer.com下载ormcomposer require topthink/think-orm装置composerapt install composer装置mysqliapt install php-pdo php-mysqli应用composer命令在指定目录装置thinkphpcomposer create-project topthink/think tp6demo
将.example.env文件批改为.env文件,配置数据库账号密码,以及开启调试;
root 123456 student true
在命令行应用以下命令开启虚构服务器,可配置域名或本地ip,我集体应用
php think run //localhost:8000
2. 引入UI
- 间接将bootstrap蕴含js和css文件夹拷贝我的项目中public/static里;
- 配置config/view.php,设置动态调用的模板门路;
//模板替换输入'tp1_replace_string' => [ '__JS__'=> '../static/js', '__CSS__' => '../static/css',],
- 控制器里新建test办法,用于测试UI引入的正确性,这时拜访页面会报错提醒没有装置驱动。下一步去装置驱动。
在命令行中执行以下命令装置驱动
composer require topthink/think-view
批改config/view.php文件为'view_suffix' => 'php',
新建模板文件index/test.php
bootstrap-theme.min.css
引入UI,留神UI在<head><title></title></hrad>
上面引入
<!-- 引入Bootstrap CSS -->{css href="/static/css/bootstrap.min.css"}{css href="/static/css/style.css"}<!-- 挪动设施优先--><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit-no">
- 创立模板文件view/index/test.html,引入UI
- 因为咱们还没有style.css文件,所以要去动态文件下的css里创立一个,内容为
@charset "UTF-8";
- 在元素里找到引入的文件,右键来到款式编辑器,看会不会显示文件内容,显示则示意引入胜利
body里引入js文件
<!-- 引入js文件 -->{js href="/static/js/jquery-3.3.1.min.js"}{js href="/static/js/bootstrap.bundle.min.js"}
3. 外围代码
按钮<button>
表格<table>
<div class="container pt-5 mt-5"> <div class="row"> <div class="col-3"> <button class="btn btn-secondary">用户治理</button> </div> <div class="col-9"> <table class="table table-bordered"> <thead class="bg-light"> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> </tr> </thead> </table> </div> </div></div>