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>
浏览器中查看源代码