作者:houxue | 来源:互联网 | 2023-02-01 17:41
我在PHP中使用Smarty模板引擎,并希望将VUE.js集成到我的应用程序中,但似乎Smarty不理解Vue.js语法(双花括号)
代码如下:
home.tpl
{include file="partials/header.tpl" title="Home"}
{include file="partials/navbar.tpl"}
Test Heading
{{ message }}
{include file="partials/footer.tpl"}
footer.tpl
app.js
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
错误信息:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:\resource\html\templates\home.tpl" on line 11 "{{ message }}" - Unexpected "{ " <-- thrown in vendor\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 11
任何帮助表示赞赏.谢谢
1> 小智..:
在你的app.js
使用中delimiters
var app = new Vue({
delimiters: ['%%', '%%'],
el: '#app',
data: {
message: 'Hello Vue!'
},
});
然后在home.tpl
包装message
用%%
{include file="partials/header.tpl" title="Home"}
{include file="partials/navbar.tpl"}
Test Heading
%% message %%
{include file="partials/footer.tpl"}