用thinkcmf5.1寫專案的時候如何實作PC端和手機端自動切換?
1.首先找到data/config/template.php檔案
復制 'cmf_admin_default_theme' => 'houtai', /houtai是后臺模板檔案夾名稱
改為 'cmf_mobile_default_theme' => 'wap', //wap是手機站模板檔案夾名稱

之后在public/theme檔案夾下復制pc端檔案夾 更改檔案夾名稱為template.php檔案中添加的名稱 (這里我的名稱是wap)

2.更改 vendor/thinkcmf/cmf/src/common.php 檔案
在vendor/thinkcmf/cmf/src/common.php 檔案中搜索 cmf_get_current_theme 這個函式是 “獲取當前主題名”
在方法中 找到 $theme = config('template.cmf_default_theme'); 這一行代碼 改為下面的判斷
if(cmf_is_mobile()){
$theme = config('template.cmf_mobile_default_theme');
}else{
$theme = config('template.cmf_default_theme');
}
如下圖:

這兩個檔案更改完成后就可以實作pc端和手機端訪問的自動切換了
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/265933.html
標籤:其他
上一篇:js制作星星閃特效
下一篇:網頁字體更清晰的css用什么?
