thinkphp配置環(huán)境引入UI(實例詳解)

本篇文章給大家?guī)砹岁P(guān)于thinkphp的相關(guān)知識,其中主要介紹了關(guān)于配置環(huán)境、引入ui的相關(guān)內(nèi)容,其中包括了配置加速源、安裝orm擴(kuò)展、安裝composer、安裝驅(qū)動、配置“config/view.php”等等問題,希望對大家有幫助。

thinkphp配置環(huán)境引入UI(實例詳解)

【相關(guān)教程推薦:thinkphp

1. 配置環(huán)境

1、配置加速源,安裝 orm 擴(kuò)展,安裝 composer, 安裝驅(qū)動,使用 composer 命令在指定的目錄安裝 thinkphp6.x;

配置conposer中國源 composer?config?-g?repo.packagist?composer?https://packagist.phpcomposer.com 下載orm composer?require?topthink/think-orm 安裝composer apt?install?composer 安裝mysqli apt?install?php-pdo?php-mysqli 使用composer命令在指定目錄安裝thinkphp composer?create-project?topthink/think?tp6demo

thinkphp配置環(huán)境引入UI(實例詳解)

立即學(xué)習(xí)PHP免費學(xué)習(xí)筆記(深入)”;

2、將.example.env 文件修改為.env 文件,配置數(shù)據(jù)庫賬號密碼,以及開啟調(diào)試;

root?123456?student?true

thinkphp配置環(huán)境引入UI(實例詳解)

3、在命令行使用以下命令開啟虛擬服務(wù)器,可配置域名或本地 ip, 我個人使用

php?think?run?????//localhost:8000

thinkphp配置環(huán)境引入UI(實例詳解)

2. 引入 UI

1、直接將 bootstrap 包含 js 和 css 文件夾拷貝項目中 public/static 里;

2、配置 config/view.php, 設(shè)置靜態(tài)調(diào)用的模板路徑;

//模板替換輸出 'tp1_replace_string'?=>?[ ????'__JS__'=>?'../static/js', ????'__CSS__'?=>?'../static/css', ],

thinkphp配置環(huán)境引入UI(實例詳解)

3、控制器里新建 test 方法,用于測試 UI 引入的正確性,這時訪問頁面會報錯提示沒有安裝驅(qū)動。下一步去安裝驅(qū)動。

thinkphp配置環(huán)境引入UI(實例詳解)

4、在命令行中執(zhí)行以下命令安裝驅(qū)動

composer?require?topthink/think-view

thinkphp配置環(huán)境引入UI(實例詳解)

修改 config/view.php 文件為’view_suffix’ => ‘php’, 新建模板文件 index/test.php

bootstrap-theme.min.css 引入 UI, 注意 UI 在

下面引入

<!-- 引入Bootstrap CSS --> {css?href="/static/css/bootstrap.min.css"} {css?href="/static/css/style.css"} <!-- 移動設(shè)備優(yōu)先--> <meta>

5、創(chuàng)建模板文件 view/index/test.html, 引入 UI

6、由于我們還沒有 style.css 文件,所以要去靜態(tài)文件下的 css 里創(chuàng)建一個,內(nèi)容為 @charset “UTF-8”;

7、在元素里找到引入的文件,右鍵來到樣式編輯器,看會不會顯示文件內(nèi)容,顯示則表示引入成功

8、body 里引入 js 文件

<!-- 引入js文件 --> {js?href="/static/js/jquery-3.3.1.min.js"} {js?href="/static/js/bootstrap.bundle.min.js"}

3. 核心代碼

按鈕

表格

<div> ????<div> ????????<div> ????????????<button>用戶管理</button> ????????</div> ????????<div> ????????????<table> ????????????????<thead> ????????????????<tr> ????????????????????<th>1</th> ????????????????????<th>2</th> ????????????????????<th>3</th> ????????????????????<th>4</th> ????????????????????<th>5</th> ????????????????</tr> ????????????????</thead> ????????????</table> ????????</div> ????</div> </div>

【相關(guān)教程推薦:thinkphp

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊10 分享