<script type="text/javascript" data-main="/order/asset/js/orderRefundChange" src="/require.js"></script>

引用了JavaScript模块化系列后,开始大展身手了,没想到,想要加载的几个模块都说404了

require.js:8 Uncaught Error: Script error for: dataTable

http://requirejs.org/docs/errors.html#scripterror

    at C (require.js:8)

    at HTMLScriptElement.onScriptError (require.js:29)

C @ require.js:8

onScriptError @ require.js:29

require.js:34 GET http://localhost:8080/order/asset/js/bootstrap.js 

g.load @ require.js:34

load @ require.js:29

load @ require.js:18

fetch @ require.js:17

check @ require.js:19

enable @ require.js:23

enable @ require.js:27

(anonymous) @ require.js:23

(anonymous) @ require.js:8

v @ require.js:7

enable @ require.js:22

init @ require.js:17

E @ require.js:14

completeLoad @ require.js:28

onScriptLoad @ require.js:29

require.js:8 Uncaught Error: Script error for: bootstrap

http://requirejs.org/docs/errors.html#scripterror

    at C (require.js:8)

    at HTMLScriptElement.onScriptError (require.js:29)

C @ require.js:8

onScriptError @ require.js:29

require.js:34 GET http://localhost:8080/order/asset/js/tpl.js 

g.load @ require.js:34

load @ require.js:29

load @ require.js:18

fetch @ require.js:17

check @ require.js:19

enable @ require.js:23

enable @ require.js:27

(anonymous) @ require.js:23

(anonymous) @ require.js:8

v @ require.js:7

enable @ require.js:22

init @ require.js:17

E @ require.js:14

completeLoad @ require.js:28

onScriptLoad @ require.js:29

require.js:8 Uncaught Error: Script error for: tpl

http://requirejs.org/docs/errors.html#scripterror

    at C (require.js:8)

    at HTMLScriptElement.onScriptError (require.js:29)

去他的地址上看错误解释:

SCRIPT ERROR

This occurs when the script.onerror function is triggered in a browser. This usually means there is a JavaScript syntax error or other execution problem running the script. To fix it, examine the script that generated the error in a script debugger.

This error may not show up in IE, just other browsers, and instead, in IE you may see the No define call for ... error when you see "Script error". This is due to IE's quirks in detecting script errors.


浏览器的console报了一大堆错误,在看配置,根本没有这几个文件,哪里自己改的呢?

require.config({
    urlArgs: "bust=" +  (new Date()).getTime(),
    baseUrl : '/order/asset/js/',
    paths : {
        jquery : 'jquery.min',
        bootstrap : 'bootstrap.min',
        dataTable:'jquery.dataTables',
        tpl:'template',
        index:"orderRefundChangeIndex"
    },
    shim : {
        bootstrap : {
            deps : [ 'jquery' ],
            exports : 'bootstrap'
        },
        dataTable:{
            deps : [ 'jquery','bootstrap' ],
            exports : 'dataTable'
        },
        tpl:{
            deps : [ 'jquery','bootstrap' ]
        },index:{
            deps : [ 'jquery','bootstrap','tpl','dataTable']
        }
    }

});
require(['jquery','bootstrap','dataTable','tpl','index'], function($,bt,dt,tp,ind) {
    $(function(){
        ind.init();
    })
});

最后发现,用控制变量法,发现data-main引用的文件必须是小写。把原来的文件

orderRefundChange

改成order_refundchange就好了

这算什么错误。。。error,sign