【发布时间】:2016-06-14 14:22:41
【问题描述】:
我正在尝试让以下代码 http://jsfiddle.net/qlmhuge/t7a1sh4u/ 在 wordpress 4.5.2 中工作。这是来自 Spotify Web API html 小部件的示例。我收到以下错误:
语法错误:# 符号上的非法字符 {{#each albums.items}}
我要运行它的网站在这里:http://dev-markandersonpianist.pantheonsite.io/discography/
这是我收到错误的脚本:
<script id="results-template" type="text/x-handlebars-template">
{{#each albums.items}}
<div style="background-image:url({{images.0.url}})" data-album-id="{{id}}" class="cover"><a href="{{external_urls.spotify}}"><div class="spotify-button"><img src="https://developer.spotify.com/wp-content/uploads/2014/06/play_on_spotify-green.png" /></div></a></div>
{{/each}}
</script>
如您在上面看到的,它在 jsFiddle 中工作。我不明白为什么它在 WordPress 中不起作用。
【问题讨论】:
-
您确定 handlebars.js 已正确安装到您的页面吗?
-
dev-markandersonpianist.pantheonsite.io/wp-content/themes/… 我认为您不应该将车把代码包含在
jQuery(function(){})中 -
我试过了,但没有用。我遇到了同样的错误。
-
当我做一个页面源把手显示加载到页面中。还有什么我可以检查的吗?
标签: javascript jquery wordpress spotify