Home > php教程 > PHP源码 > body text

ThinkPHP里用U方法调用js文件

PHP中文网
Release: 2016-05-25 17:15:10
Original
1169 people have browsed it

ThinkPHP里用U方法调用js文件

/*在TP里提供了在模板文件中直接调用函数的快捷方法。U是其中之一。手册里有它的用法:
{:U(&#39;User/insert&#39; )} <br>
先把js文件的后缀改成html(这个不会影响),然后写个JsAction,在里面进行调用:*/
<?php
class JsAction extends Action{
    function nav() {
        $this->display(&#39;Index:js:nav&#39;);
    }
}
?>
/*最后,把左框架里的JS链接改一下:*/
<script type="text/javascript" src="{:U(&#39;Js/nav&#39;)}"></script>
Copy after login


 以上就是ThinkPHP里用U方法调用js文件的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!