首页  >  文章  >  web前端  >  解决css和js的{}与smarty定界符冲突问题的两种方法_javascript技巧

解决css和js的{}与smarty定界符冲突问题的两种方法_javascript技巧

WBOY
WBOY原创
2016-05-16 17:22:571123浏览

当输入url地址后网页出现:Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "E:wampwwwcmssystem/templates/index.html" on line 79 "$("#job").load("./system/templates/touch/test.php",{catid:3});" - Unexpected ":", expected one of: "}" , " "' in E:wampwwwcmssystemSmartysyspluginssmarty_internal_templatecompilerbase.php on line 441这样的问题,通常是css和js的{}与smarty定界符冲突导致的。

解决办法有两个:

1.可以把 smarty 的定界符设成 <{ }>

复制代码 代码如下:

$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';

2.对于js的{}与smarty定界符冲突,可以用smarty的literal处理,可以把JS代码包含在{literal}{/literal}之间就可以了。
复制代码 代码如下:

<{literal}>
$ (
function () { alert ('培训课程')}
);
<{/literal}>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn