tp6引入靜態資源
阿新 • • 發佈:2020-12-28
技術標籤:thinkphp框架thinkphp
tp6引入css,js等靜態資源
將css,js等靜態資源新增到public/static目錄下,
在config/view.php檔案中新增程式碼
//靜態資源 'tpl_replace_string' => [ '__CSS__' => 'static/index/css', '__JS__' => 'static/index/js', '__IMG__' => 'static/index/images', '__FONT__' => 'static/index/font' ]
模板檔案中就可以使用自定義的檔案路徑了
<head>
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css">
<link rel="stylesheet" type="text/css" href="__CSS__/iconfont.css">
<link rel="stylesheet" type="text/css" href="__CSS__/swiper.min.css" >
<link rel="stylesheet" type="text/css" href="__CSS__/index.css">
</head>
瀏覽器中檢視原始碼