This article describes the method of using U method to call js files in ThinkPHP. Share it with everyone for your reference. The details are as follows:
TP provides a shortcut method to directly call functions in template files. U is one of them. Its usage is in the manual:
Copy code The code is as follows: {:U('User/insert' )}
First change the suffix of the js file to html (this will not affect it), then write a JsAction and call it in it:
<?php class JsAction extends Action{ function nav() { $this->display('Index:js:nav'); } } ?> //最后,把左框架里的JS链接改一下: <script type="text/javascript" src="{:U('Js/nav')}"></script>
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.