Home > php教程 > php手册 > PHP 的 Smarty 模板页中分离JS并避开literal标签的解决方法

PHP 的 Smarty 模板页中分离JS并避开literal标签的解决方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:40:24
Original
1181 people have browsed it

在 Smartry 模板 中,如何 分离 而做到 避开 {literal} 呢? 本人的 解决 方法 是: {} 符号的JS变量。示例如下: script type="text/javascript" var __URL = "{$DOMAIN['LOCAL_DOMAIN']}", areaInfo = {$areaInfo}, widgetID = "{$widgetID}"; /script 然

在 Smartry 模板中,如何分离而做到避开{literal}呢?

本人的解决方法是:

{}符号的JS变量。示例如下:

<script type="text/javascript"><br>var __URL = "{$DOMAIN['LOCAL_DOMAIN']}",<br>   areaInfo = {$areaInfo},<br>   widgetID = "{$widgetID}";<br></script> 
Copy after login

然后,再引用后面的JS文件:

<script type="text/javascript" src="%7B%24DOMAIN.JS_DOMAIN%7Dperson_map/index.js"></script>
Copy after login

这样,后端与前端可以同时开发,tpl 模板文件只作为了前后端之间公共的部分。

(完)

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template