requirejs blueimp fileuploader 只加载 min.js 文件,没有其他文件 [英] requirejs blueimp fileuploader only loads min.js files and none other

查看:27
本文介绍了requirejs blueimp fileuploader 只加载 min.js 文件,没有其他文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是 requirejs 和主干的菜鸟,但我试图在我的本地机器上加载 blueimp 文件上传器的所有依赖项,而不加载任何外部脚本.这是我的 config.js 文件:

so I'm a noobie to requirejs and backbone, but I'm trying to load in all the dependencies for blueimp file uploader on my local machine and not load any external scripts. here is my config.js file:

// Set the require.js configuration for your application.
require.config({

  // Initialize the application with the main application file.
  deps: ["main"],

  paths: {
    // JavaScript folders.
    libs: "../assets/js/libs",
    plugins: "../assets/js/plugins",
    vendor: "../assets/vendor",
    api : "../assets/js/libs/api",

    // Libraries.
    jquery: "../assets/js/libs/jquery",
    jqueryui: "../assets/js/libs/jquery-ui",
    lodash: "../assets/js/libs/lodash",
    backbone: "../assets/js/libs/backbone",
    handlebars: "../assets/js/libs/handlebars",
    bootstrap : "../assets/js/libs/bootstrap",
    jqueryuiwidget : '../assets/js/libs/jquery.ui.widget',
    jstemplates : '../assets/js/libs/tmpl.min',
    jsloadimage : '../assets/js/libs/load-image.min',
    jscanvastoblob : '../assets/js/libs/canvas-to-blob.min',
    iframetransport : '../assets/js/libs/jquery.iframe-transport',
    fileupload : '../assets/js/libs/jquery.fileupload',
    fileuploadfp : '../assets/js/libs/jquery.fileupload-fp',
    fileuploadui : '../assets/js/libs/jquery.fileupload-ui'
  },

  shim: {
    // Backbone library depends on lodash and jQuery.
    backbone: {
      deps: ["lodash", "jquery", "jqueryui", "api", 'jqueryuiwidget', 'jstemplates', 'jsloadimage', 'jscanvastoblob', 'iframetransport', 'fileupload', 'fileuploadfp', 'fileuploadui'],
      exports: "Backbone"
    },

    handlebars : {
        attach: "Handlebars"
    },

    api : {
        attach : "api"
    },

    bootstrap: {
      deps: ["jquery"]
    },

    // Backbone.LayoutManager depends on Backbone.
    "plugins/backbone.layoutmanager": ["backbone"]
  }

});

我知道我不应该将所有其他文件作为主干的依赖项,但我只是想加载它.

i know I'm not supposed to put all those other files as dependencies for backbone, but I'm just trying to get the thing to load.

结果是,它加载时没有任何错误,但当我查看页面时,它只加载了 canvas-to-blob.min.js、load-image.min.js 和 tmpl.min.js.

what happens is, it loads without any errors, but when I look at the page it only has loaded canvas-to-blob.min.js, load-image.min.js, and tmpl.min.js.

有什么想法为什么会这样吗?这很奇怪,因为例如,如果我将其他文件之一的路径更改为错误,则该内容会抛出错误并失败,就好像它试图加载它一样.但是当它的路径正确时,它就不会加载...

Any thoughts why this might be? It's weird because for example if i change the path on one of the other files to be wrong, the thing will throw and error and fail as if its trying to load it. but when its the right path, it just doesn't load...

推荐答案

shim: {

backbone: {
  deps: ["lodash", "jquery"],
  exports: "Backbone"
},

bootstrap: { deps: ["jquery"] },
widget: { deps: ["jquery"] },

// backbone plugins
"plugins/backbone.layoutmanager": ["backbone"], 
"lib/jquery.fileupload": ["jquery", "widget"],
"lib/jquery.fileupload-fp": ["jquery", "lib/load-image", "lib/canvas-to-blob",        
"lib/jquery.fileupload"],
"lib/jquery.fileupload-ui": ["jquery", "lib/tmpl", "lib/load-image",  
"lib/jquery.fileupload-fp"]
}

并且您必须在所有js文件的define[]部分中通过配置中的路径变量替换路径我做了同样的事情,它对我有用.

And you have to replace paths by path variables from config in define[] part of all js files I have done the same and it is working for me.

这篇关于requirejs blueimp fileuploader 只加载 min.js 文件,没有其他文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆