Blogger Information
Blog 34
fans 0
comment 0
visits 39164
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp5.1静态文件引用及配置
黄健的博客
Original
3473 people have browsed it

https://blog.csdn.net/qq_36308324/article/details/61922373

我自己犯了个错误,tp5的index.php入口文件在public文件夹下。静态文件的引用就不能加上public,

    错误: /public/static/index/js

    正确 : /static/index/js


静态文件引用配置

    模块下的配置文件夹的template.php文件中

        例: index/config/template.php

            

                return[
                    'tpl_replace_string' => [
                    
                            '__JS__'  =>  '/static/'.Request::module().'/js',
                        ],
                ];

                Request::module() 获得当前模块名

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