简单模板化Dijit抛出空解析错误

时间:2013-02-13 20:49:21

标签: dojo

有时我真的好奇我不只是使用jQuery ......

基本模板化Dijit:

define([
    'dojo/_base/declare',
    'dijit/_WidgetBase',
    'dijit/_TemplatedMixin',
    'dijit/_WidgetsInTemplateMixin',
    'dojo/text!./templates/basic.html'
    ],
function(
    declare,
    _WidgetBase,
    _TemplatedMixin,
    _WidgetsInTemplate,
    template
    ) {
    return declare("Slider", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplate], {
        templateString : template
    })
})

模板:

<div class="${baseClass}">
    <div data-role="decor" data-dojo-type="gs/ImageBox/ImageBox">
        <header>
            <h2>Air Jordan 6</h2>
            <h6>2000</h6>
        </header>
        <footer>
            <a href="javascript:void(0);" data-role="toggle">More Information</a>
        </footer>
    </div>
    <div data-role="content">
        <section class="data">
            <header>
                <a href="javascript:void(0);" data-role="toggle" class="sticky">Hide</a>
                <ul class="list_info">
                    <li><span>Release Date</span><span>3.15.2003</span></li>
                    <li><span>Release Type</span><span>General Release</span></li>
                    <li><span>Cost at release</span> <span>$100</span></li>
                    <li><span>Cost Today</span> <span>$325-$600</span></li>
                </ul>
            </header>
            <!--
            <div data-dojo-type="dijit/layout/ContentPane" href="./php/info.php?id=3"></div>
            -->
        </section>
    </div>
</div>

引发通用解析错误。如果我删除data-dojo-type="gs/ImageBox/ImageBox"声明,它至少会解析。

Dojo配置:

<script>
dojoConfig = {
    parseOnLoad : false,
    async : true,
    cacheBust : true,
    packages : [
        { name : 'gs', location: location.pathname.replace(/\/[^/]*$/, '/js') }
    ],
    debug : true,
    debugAtAllCosts : true
}
</script>

如果Dojo在某些信息中引发错误,那就太棒了,但它只是在dojo.js第22行给出parse error()

让我发疯。

2 个答案:

答案 0 :(得分:1)

我认为你需要告诉AMD加载器你需要gs/ImageBox/ImageBox

define([
  'dojo/_base/declare',
  'dijit/_WidgetBase',
  'dijit/_TemplatedMixin',
  'dijit/_WidgetsInTemplateMixin',
  'gs/ImageBox/ImageBox',
  'dojo/text!./templates/basic.html'
], function(
   declare,
  _WidgetBase,
  _TemplatedMixin,
  _WidgetsInTemplate,
  ImageBox,
  template
) {

答案 1 :(得分:1)

帖子的第一行应该是“我不知道为什么我这么(blind|stupid)”。

模板实际上的第一行有一条评论作为第一行。很大禁忌。