简体   繁体   English

获取错误,包括handlebars.js

[英]Getting error including handlebars.js

I just started playing with handlebars.js and am getting an error from within handlebars.js which seems very odd : "define is not defined" . 我刚刚开始使用handlebars.js,并且从handlebars.js中收到一个错误,这似乎很奇怪:“未定义定义”。 If someone can point out my mistake, I'd much appreciate it. 如果有人能指出我的错误,我将不胜感激。 Below is my code snippet and below that is a pix of the chrome dev tools error. 下面是我的代码段,下面是chrome dev tools错误的图片。

<script id="entry-template" type="text/x-handlebars-template">
    <div class="entry">
        <h1>{{title}}</h1>
        <div class="body">
            {{body}}
        </div>
    </div>
</script>

<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.amd.js"></script>

<script>
    $(document).ready(function() {
        var source   = $("#entry-template").html();
        var template = Handlebars.compile(source);
    })
</script>

在此处输入图片说明

any reason you are referencing the amd file? 您引用amd文件有任何原因吗? if not here is the cdn not throwing the error. 如果不是,那是CDN不抛出错误。

 <script id="entry-template" type="text/x-handlebars-template"> <div class="entry"> <h1>{{title}}</h1> <div class="body"> {{body}} </div> </div> </script> <script src="https://code.jquery.com/jquery-2.1.3.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.js"></script> <script> $(document).ready(function() { var source = $("#entry-template").html(); var template = Handlebars.compile(source); }) </script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM