Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 09:00:50
Original
847 people have browsed it

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

本文实例讲述了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 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!