Home  >  Article  >  php教程  >  ThinkPHP里用U方法调用js文件

ThinkPHP里用U方法调用js文件

PHP中文网
PHP中文网Original
2016-05-25 17:15:101170browse

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>


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


Statement:
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