-1
我正在使用車把,它在開發中工作正常。當我上傳到github頁面時,如果我直接打開頁面,handlebars模板仍然有效。但是,如果我去鏈接中的頁面,句柄循環不起作用。這裏是我的代碼:鏈接點擊後生產車把不工作
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="../bower_components/handlebars/handlebars.min.js"></script>
</head>
<div id="content-placeholder"></div>
<script id="some-template" type="text/x-handlebars-template">
{{#each this}}
<div class=" col-md-4 col-sm-6 " data-animation-type="fadeIn" data-animation-delay="0.5s" data-animation-duration="2s">
<div class="item-wrap">
<figure class="">
<div class="popup-call">
<a href="assets/custom/images/blog/01.jpg" class="gallery-item"><i class="flaticon-arrows-4"></i></a>
</div>
<img src="{{this.picture.picture.url}}" class="img-responsive" style="height: 200px" alt="img11"/>
<figcaption>
<div class="post-header">
<h5><a href="blogpost.html">{{this.name}}</a></h5>
</div>
</figcaption>
</figure>
</div>
</div>
{{/each}}
</script>
<script>
$(document).ready(function(){
var source = $("#some-template").html();
var template = Handlebars.compile(source);
$.getJSON('https://my-url.com/teams.json', function(data){
console.log(data);
$("#content-placeholder").html(template(data));
});
});
</script>
我試着這樣做沒有document.ready()
但是,這並不能改變什麼。
什麼是在您的JavaScript控制檯? –
我猜測Handlebars沒有被加載,因爲URL被改變了。包括如何將它加載到頁眉中。 –
沒有什麼在JavaScript控制檯 – Philip7899