jquery - RequireJS + jQuery 命名空间问题

标签 jquery namespaces requirejs optimization r.js

如果我在没有“namespace: 'foo'”标志的情况下运行优化器,一切都会按预期工作。当我将“namespace: 'foo'”添加到 app.build.js 中时,出现此错误:

GET: file:// (path to the project) /require-jquery/jquery-require-sample/webapp/jquery.js
main-built.js:main-built.js:1839

Uncaught Error: Script error http://requirejs.org/docs/errors.html#scripterror
main-built.js:163

我已经四处寻找解决方案,但关于使用 RequireJS 优化器使用 jquery 和命名空间导出单个文件的信息很少。谢谢!

我已经放置了 RequireJS + jQuery 示例项目(带有修改后的 app.build.js 和 app.html)on github here.

({
    baseUrl: ".",
    out: 'main-built.js',
    //Comment out the optimize line if you want
    //the code minified by UglifyJS
    optimize: "none",

    paths: {
        "jquery": "require-jquery"
    },

    name: 'main',
    namespace: 'foo'
})

最佳答案

尝试删除名称参数(除非您确实需要它)。

关于jquery - RequireJS + jQuery 命名空间问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13847344/

相关文章:

jquery - Phonegap、cookie、跨域请求

javascript - 通过带有angularjs和ionic的html img标签显示图像

xml - 制作新的 XML 标签时,它们是否需要位于命名空间中?

javascript - 使用 grunt 设置等待秒数

javascript - RactiveJS 国际化的良好实践(使用 RequireJS)

javascript - 如何获取单击行的 id 并使用该 id 显示该行的信息 - 使用backbone.js

jquery - JCrop - JCrop 支架在移动/调整选择大小时显示不正确的图像

python - 使用 Python globals() 处理动态类的最佳方法

c# - 为什么我收到错误 CS0246 : The type or namespace name could not be found?

javascript - 需要 js Backbone JS 全局模型