Blogger Information
Blog 12
fans 0
comment 0
visits 12717
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkphp5.1 在模板文件中引入CSS/JS
留情的博客
Original
3402 people have browsed it

在模板文件中引入CSS/JS

官方提供的方法

{js href="/static/js/jquery.js" /}
{css href="/static/css/bootstrap.css" /}

也可以在配置文件夹config/template.php中添加自定义配置

return [    // 模板引擎类型 支持 php think 支持扩展
    'type'         => 'Think',    // 模板路径
    'view_path'    => '',    // 模板后缀
    'view_suffix'  => 'html',    // 模板文件名分隔符
    'view_depr'    => DIRECTORY_SEPARATOR,    // 模板引擎普通标签开始标记
    'tpl_begin'    => '{',    // 模板引擎普通标签结束标记
    'tpl_end'      => '}',    // 标签库标签开始标记
    'taglib_begin' => '{',    // 标签库标签结束标记
    'taglib_end'   => '}',    // 模板路径替换
        'tpl_replace_string' =>[   '__STATIC__'=>'/static',
],
];

如果tpl_replace_string没有起效的话就需要清空下模板的缓存
在根目录下thinkphp/library/think/Template.php设置

'cache_time'         => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒)
//可将0设置为1,快速将缓存清空,记得设置成功后将cache_time设置为0


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!