Home > Backend Development > PHP Tutorial > ThinkPHP里用U方法调用js文件实例_PHP

ThinkPHP里用U方法调用js文件实例_PHP

WBOY
Release: 2016-05-30 08:44:56
Original
1008 people have browsed it

本文实例讲述了ThinkPHP里用U方法调用js文件的方法。分享给大家供大家参考。具体如下:

在TP里提供了在模板文件中直接调用函数的快捷方法。U是其中之一。手册里有它的用法:

代码如下:

{:U('User/insert' )}

先把js文件的后缀改成html(这个不会影响),然后写个JsAction,在里面进行调用:

<&#63;php
class JsAction extends Action{
  function nav() {
    $this->display('Index:js:nav');
  }
}
&#63;>
//最后,把左框架里的JS链接改一下:
<script type="text/javascript" src="{:U('Js/nav')}"></script>

Copy after login

希望本文所述对大家基于ThinkPHP框架的php程序设计有所帮助。

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template