1. 程式人生 > 其它 >ThinkPHP配置靜態資源地址

ThinkPHP配置靜態資源地址

技術標籤:phpThinkPHP配置靜態資源靜態資源目錄靜態資源地址

首先開啟 application/index 目錄新建一個 config/template.php 檔案

<?php

return [
    'tpl_replace_string'    =>      [
        '__CSS__'=>'/static/index/css',// 這裡指向/public/static/index/css目錄
        '__JS__' => '/static/index/js',// 這裡指向/public/static/index/js目錄
        '__IMG__' => '/static/index/img',// 這裡指向/public/static/index/img目錄
    ]
];

定義了三個常量 __CSS____JS____IMG__

頁面引入靜態資源這樣使用路徑即可,【靜態資源一般都放置在 /public/static 目錄下 】


個人部落格