js 中 define定义的函数怎么调用? uploadModule
}), define("uploadModule", ["common/global", "fileUpload"], function (e) {

解决方案 »

  1.   


    (function () {
        "use strict";    function e(e) {
            var i = "dragover" === e;
            return function (s) {
                s.dataTransfer = s.originalEvent && s.originalEvent.dataTransfer;
                var n = s.dataTransfer;
                n && -1 !== t.inArray("Files", n.types) && !1 !== this._trigger(e, t.Event(e, {
                    delegatedEvent: s
                })) && (s.preventDefault(), i && (n.dropEffect = "copy"))
            }
        }
        var t = jQuery;
        t.support.fileInput = !(new RegExp("(Android (1\\.[0156]|2\\.[01]))|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)|(w(eb)?OSBrowser)|(webOS)|(Kindle/(1\\.0|2\\.[05]|3\\.0))").test(window.navigator.userAgent) || t('<input type="file">').prop("disabled")), t.support.xhrFileUpload = !(!window.ProgressEvent || !window.FileReader), t.support.xhrFormDataFileUpload = !!window.FormData, t.support.blobSlice = window.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice), t.widget("blueimp.fileupload", {
            options: {
                dropZone: t(document),
                pasteZone: void 0,
                fileInput: void 0,
                replaceFileInput: !0,
                paramName: void 0,
                singleFileUploads: !0,
                limitMultiFileUploads: void 0,
                limitMultiFileUploadSize: void 0,
                limitMultiFileUploadSizeOverhead: 512,
                sequentialUploads: !1,
                limitConcurrentUploads: void 0,
                forceIframeTransport: !1,
                redirect: void 0,
                redirectParamName: void 0,
                postMessage: void 0,
                multipart: !0,
                maxChunkSize: void 0,
                uploadedBytes: void 0,
                recalculateProgress: !0,
                progressInterval: 100,
                bitrateInterval: 500,
                autoUpload: !0,
                messages: {
                    uploadedBytes: "Uploaded bytes exceed file size"
                },
                i18n: function (e, i) {
                    return e = this.messages[e] || e.toString(), i && t.each(i, function (t, i) {
                        e = e.replace("{" + t + "}", i)
                    }), e
                },
                formData: function (e) {
                    return e.serializeArray()
                },
                add: function (e, i) {
                    if (e.isDefaultPrevented()) return !1;
                    (i.autoUpload || !1 !== i.autoUpload && t(this).fileupload("option", "autoUpload")) && i.process().done(function () {
                        i.submit()
                    })
                },
                processData: !1,
                contentType: !1,
                cache: !1
            },
            _specialOptions: ["fileInput", "dropZone", "pasteZone", "multipart", "forceIframeTransport"],
            _blobSlice: t.support.blobSlice &&
    function () {
        return (this.slice || this.webkitSlice || this.mozSlice).apply(this, arguments)
    },
            _BitrateTimer: function () {
                this.timestamp = Date.now ? Date.now() : (new Date).getTime(), this.loaded = 0, this.bitrate = 0, this.getBitrate = function (e, t, i) {
                    var s = e - this.timestamp;
                    return (!this.bitrate || !i || s > i) && (this.bitrate = (t - this.loaded) * (1e3 / s) * 8, this.loaded = t, this.timestamp = e), this.bitrate
                }
            },
            _isXHRUpload: function (e) {
                return !e.forceIframeTransport && (!e.multipart && t.support.xhrFileUpload || t.support.xhrFormDataFileUpload)
            },
            _getFormData: function (e) {
                var i;
                return "function" === t.type(e.formData) ? e.formData(e.form) : t.isArray(e.formData) ? e.formData : "object" === t.type(e.formData) ? (i = [], t.each(e.formData, function (e, t) {
                    i.push({
                        name: e,
                        value: t
                    })
                }), i) : []
            },
            _getTotal: function (e) {
                var i = 0;
                return t.each(e, function (e, t) {
                    i += t.size || 1
                }), i
            },
            _initProgressObject: function (e) {
                var i = {
                    loaded: 0,
                    total: 0,
                    bitrate: 0
                };
                e._progress ? t.extend(e._progress, i) : e._progress = i
            },
            _initResponseObject: function (e) {
                var t;
                if (e._response) for (t in e._response) e._response.hasOwnProperty(t) && delete e._response[t];
                else e._response = {}
            },
            _onProgress: function (e, i) {
                if (e.lengthComputable) {
                    var s, n = Date.now ? Date.now() : (new Date).getTime();
                    if (i._time && i.progressInterval && n - i._time < i.progressInterval && e.loaded !== e.total) return;
                    i._time = n, s = Math.floor(e.loaded / e.total * (i.chunkSize || i._progress.total)) + (i.uploadedBytes || 0), this._progress.loaded += s - i._progress.loaded, this._progress.bitrate = this._bitrateTimer.getBitrate(n, this._progress.loaded, i.bitrateInterval), i._progress.loaded = i.loaded = s, i._progress.bitrate = i.bitrate = i._bitrateTimer.getBitrate(n, s, i.bitrateInterval), this._trigger("progress", t.Event("progress", {
                        delegatedEvent: e
                    }), i), this._trigger("progressall", t.Event("progressall", {
                        delegatedEvent: e
                    }), this._progress)
                }
            },
            _initProgressListener: function (e) {
                var i = this,
    s = e.xhr ? e.xhr() : t.ajaxSettings.xhr();
                s.upload && (t(s.upload).bind("progress", function (t) {
                    var s = t.originalEvent;
                    t.lengthComputable = s.lengthComputable, t.loaded = s.loaded, t.total = s.total, i._onProgress(t, e)
                }), e.xhr = function () {
                    return s
                })
            },
            _isInstanceOf: function (e, t) {
                return Object.prototype.toString.call(t) === "[object " + e + "]"
            },
            _initXHRData: function (e) {
                var i, s = this,
    n = e.files[0],
    a = e.multipart || !t.support.xhrFileUpload,
    r = "array" === t.type(e.paramName) ? e.paramName[0] : e.paramName;
                e.headers = t.extend({}, e.headers), e.contentRange && (e.headers["Content-Range"] = e.contentRange), a && !e.blob && this._isInstanceOf("File", n) || (e.headers["Content-Disposition"] = 'attachment; filename="' + encodeURI(n.name) + '"'), a ? t.support.xhrFormDataFileUpload && (e.postMessage ? (i = this._getFormData(e), e.blob ? i.push({
                    name: r,
                    value: e.blob
                }) : t.each(e.files, function (s, n) {
                    i.push({
                        name: "array" === t.type(e.paramName) && e.paramName[s] || r,
                        value: n
                    })
                })) : (s._isInstanceOf("FormData", e.formData) ? i = e.formData : (i = new FormData, t.each(this._getFormData(e), function (e, t) {
                    i.append(t.name, t.value)
                })), e.blob ? i.append(r, e.blob, n.name) : t.each(e.files, function (n, a) {
                    (s._isInstanceOf("File", a) || s._isInstanceOf("Blob", a)) && i.append("array" === t.type(e.paramName) && e.paramName[n] || r, a, a.uploadName || a.name)
                })), e.data = i) : (e.contentType = n.type || "application/octet-stream", e.data = e.blob || n), e.blob = null
            },
            _initIframeSettings: function (e) {
                var i = t("<a></a>").prop("href", e.url).prop("host");
                e.dataType = "iframe " + (e.dataType || ""), e.formData = this._getFormData(e), e.redirect && i && i !== location.host && e.formData.push({
                    name: e.redirectParamName || "redirect",
                    value: e.redirect
                })
            },
            _initDataSettings: function (e) {
                this._isXHRUpload(e) ? (this._chunkedUpload(e, !0) || (e.data || this._initXHRData(e), this._initProgressListener(e)), e.postMessage && (e.dataType = "postmessage " + (e.dataType || ""))) : this._initIframeSettings(e)
            },
            _getParamName: function (e) {
                var i = t(e.fileInput),
    s = e.paramName;
                return s ? t.isArray(s) || (s = [s]) : (s = [], i.each(function () {
                    for (var e = t(this), i = e.prop("name") || "files[]", n = (e.prop("files") || [1]).length; n;) s.push(i), n -= 1
                }), s.length || (s = [i.prop("name") || "files[]"])), s
            },
            _initFormSettings: function (e) {
                e.form && e.form.length || (e.form = t(e.fileInput.prop("form")), e.form.length || (e.form = t(this.options.fileInput.prop("form")))), e.paramName = this._getParamName(e), e.url || (e.url = e.form.prop("action") || location.href), e.type = (e.type || "string" === t.type(e.form.prop("method")) && e.form.prop("method") || "").toUpperCase(), "POST" !== e.type && "PUT" !== e.type && "PATCH" !== e.type && (e.type = "POST"), e.formAcceptCharset || (e.formAcceptCharset = e.form.attr("accept-charset"))
            },
            _getAJAXSettings: function (e) {
                var i = t.extend({}, this.options, e);
                return this._initFormSettings(i), this._initDataSettings(i), i
            },
            _getDeferredState: function (e) {
                return e.state ? e.state() : e.isResolved() ? "resolved" : e.isRejected() ? "rejected" : "pending"
            },
            _enhancePromise: function (e) {
                return e.success = e.done, e.error = e.fail, e.complete = e.always, e
            },
            _getXHRPromise: function (e, i, s) {
                var n = t.Deferred(),
    a = n.promise();
                return i = i || this.options.context || a, !0 === e ? n.resolveWith(i, s) : !1 === e && n.rejectWith(i, s), a.abort = n.promise, this._enhancePromise(a)
            },
            _addConvenienceMethods: function (e, i) {
                var s = this,
    n = function (e) {
        return t.Deferred().resolveWith(s, e).promise()
    };
                i.pr
      

  2.   

    define()是requireJS的语法,通过require()引用;define("aaa",[],function(){})
    require(["aaa"],function(aaa){/// aaa 接收aaa模块暴露的方法,没有暴露则可以不写})
      

  3.   

    我定义的这个怎么调用?
    define("uploadModule", ["common/global", "fileUpload"], function (e) {
    }
      

  4.   

           require(["uploadModule"], function (uploadModule) {/// aaa 接收aaa模块暴露的方法,没有暴露则可以不写
                uploadModule.initUpload();            alert();
            })
      

  5.   

    异常为 Uncaught ReferenceError: require is not defined
      

  6.   

    requireJS的用法= =
    在页面中引入 require.js ; data-main后面的路径指向你需要引入的JS,这样才能在自己的js中写requirejs的语法<script src="js/lib/require.js/require.js" data-main="js/list"></script>
      

  7.   

    比较简单,你可以自己百度多看几个requireJS的使用例子就清楚了
      

  8.   

    如果difine有暴露方法就直接使用接收的变量就可以了,比如使用jqueryrequire(["jquery"],function($){//$符号就是jquery暴露出来的方法
         $(function(){     })
    })
      

  9.   


        return Backbone.View.extend({
            el: "#file-upload-module",
            TPL: '<div class="J_image_upload mr10 mt10 <%- className %> <%- idx == 0 ? \'image-btn\'  : \'\' %> <%if(idx==0){%><%-hideClass%><%}%>"><div class="image-select J-image-select empty"><div class="image-preview"></div><div class="image-upload"><input type="hidden" name="is_protected" value="true" /><input type="hidden" name="type" value="1" /><input type="hidden" name="owner_type" value="1" /><input type="hidden" name="media_type" value="image" /><input type="hidden" name="dispositionType" value="1" /><% if(!isMobile){ %><input type="file" multiple name="<%- paramName %>" class="J-image-upload"> <% } else { %><input type="file" name="<%- paramName %>" class="J-image-upload" accept="image/*"> <% } %><% if(idx !== 0){ %><input type="hidden" class="J-ipt-hidden" name="images[]" ><% } %><a class="btn btn-default btn-sm J-image-btn"><%- addText %></a></div></div></div>',
            modalTpl: '<div class="modal fade in" id="imageShowModal" tabindex="-1" role="dialog" aria-labelledby="imageShowModalLabel" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title" id="imageShowModalLabel">大图预览</h4></div><div class="modal-body" style="text-align: center"><img src="" class="J-modal-img"/></div><div class="modal-footer modal-btn-col1"><button type="button" class="btn btn-default J-img-cancel" data-dismiss="modal">取消</button></div></div></div></div>',
            events: {
                "click .J-image-btn": "toggleImage",
                "click .J-image-upload": "addImage",
                "click .image-preview": "showImageModal"
            },
            initialize: function(e, t) {            alert();
                var i = this,
    s = "/japi/platform/115020002";
                $("#J-clinic-edit-manage").length && (s = "/Union/imageUpload"), i.config = $.extend({
                    loadingText: "上传中",
                    addText: "上传文件",
                    delText: "删除文件",
                    editText: "编辑文件",
                    className: "col-sm-3",
                    hideClass: "",
                    returnType: "&pattern=200",
                    paramName: "uploadFile",
                    url: s,
                    maxFileSize: 20971520,
                    acceptFileTypes: /(\.|\/)(jpe?g|gif|png|bmp)$/i,
                    multiple: !0,
                    limit: 10,
                    addFnBefore: null,
                    finishFnBefore: null,
                    failedFn: i.progressError,
                    progressFn: i.progressLoad
                }, e), i.option = t, i.config.el && (i.el = i.config.el), !$("body").find("#imageShowModal").length && $("body").append(i.modalTpl), i.addItem(0), i.initUpload()
            },
     我要掉这个  initialize: function(e, t) { } 这个e 和t是什么?
      

  10.   

    djw1299969195 备注一下