Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jello模板继承和资源加载问题 #64

Open
bigdogaaa opened this issue Aug 6, 2015 · 3 comments
Open

jello模板继承和资源加载问题 #64

bigdogaaa opened this issue Aug 6, 2015 · 3 comments

Comments

@bigdogaaa
Copy link

模板vm中这么写的

<!DOCTYPE html>
#html("/static/js/require.js")

    #head()
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>$title #if( $titleAffix ) - $titleAffix#end</title>
        <link rel="shortcut icon" type="image/x-icon" href="/static/favicon.ico" />

        #require("/static/css/bootstrap.css")
        #require("/static/font-awesome/css/font-awesome.css")
        #require("/static/css/plugins/codemirror/codemirror.css")
        #require("/static/css/plugins/codemirror/ambiance.css")
        #require("/static/css/style.css")
        <!-- Mainly scripts -->
        #require("/static/js/jquery-2.1.1.js")
        #require("/static/js/bootstrap.min.js")
        #require("/static/js/plugins/metisMenu/jquery.metisMenu.js")
        #require("/static/js/plugins/slimscroll/jquery.slimscroll.min.js")
        <!-- Data Tables -->
        #require("/static/js/plugins/dataTables/jquery.dataTables.js")
        #require("/static/js/plugins/dataTables/dataTables.bootstrap.js")
        #require("/static/js/plugins/dataTables/dataTables.responsive.js")
        #require("/static/js/plugins/dataTables/dataTables.tableTools.min.js")
        <!-- Custom and plugin javascript -->
        #require("/static/js/inspinia.js")
        #require("/static/js/plugins/pace/pace.min.js")
    #end## end head

    #body("class", "fixed-sidebar full-height-layout")

        <div id="wrapper">
            ## 定义一个区域
            #block("body")#end
        </div>

    #end## end of body


    ## 需要依赖一下自己,否则该 vm 中依赖没法自动加载进来。
    #require("./frame.vm")
#end## end of html

加载的时候 _dataTables_的插件全部出问题。
读不到_dataTable_的属性,还有会报Mismatched anonymous define() module的错
没有用过require.JS,看官网的说明没太理解,是不是不支持require.JS的第三方类库我都得自己
define成require的模块?

上面是模板文件,继承模板文件的vm:

#extends("/page/assets/layout/frame.vm")

    #block("body")
        ## 导航栏
        #widget("/widget/nav/nav.vm")

        <div id="page-wrapper" class="gray-bg">

            #block("bottom")
                #widget("/widget/bottom/bottom.vm")
            #end
            #block("header")
                #widget("/widget/header/header.vm")
            #end
            #block("content")
                #widget("/widget/breadcrumb-form/breadcrumb-form.vm")
            #end
            #block("footer")
                ## 页脚
                #widget("/widget/footer/footer.vm")
            #end
        </div>
    #end

    ## 需要依赖一下自己,否则该 vm 中依赖没法自动加载进来。
    #require("./assets.vm")
#end
}

看chrome的控制台,发现资源全都加载进来了,但是并没有全部对页面起作用,样式都出问题了。

感觉上是我require的用法不对,望指点

@2betop
Copy link
Contributor

2betop commented Aug 6, 2015

你需要用 js 的 require 启动一下。听你的描述是只是 define 了模块,但是没用使用。

@bigdogaaa
Copy link
Author

模板文件中用了很多的require,应该算是启动了吧?
浏览器中打开继承模板的页面时 datatables插件全部出问题,
报Error: Mismatched anonymous define() module: function ( $, DataTable ) {...

datatables插件的js文件我没有修改过,并没有加define之类的,那我的模块是什么时候定义的?

@zuojj
Copy link

zuojj commented Jan 5, 2016

是不是没有require('module id') ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants