1

プロジェクトで「定義」を使用しています。オプティマイザを使用しないと、js コードが動作しません。オプティマイザーを実行すると、すべてのファイルが以下に含まれます

require(["jquery", "modals", "registermodule", "bootstrap", "personsmodule", "datemodule",    "./jquery-ui-1.8.18.custom.min"], function($) {});


C:/Users/pethel/checkout/src/main/webapp/resources/scripts/main-built.js
----------------
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/jquery.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/modals.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/ajaxmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/jquery-ui-1.8.18.custom.min.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/datemodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/validationmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/guimodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/registration_util.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/registermodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/bootstrap.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/tablesort.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/personsmodule.js
C:/Users/pethel/checkout/src/main/webapp/resources/scripts/main.js

醜いスクリプトでページを読み込むと、datepicker が定義されていません。jquery-ui-1.8.18.custom.min.js にファイルが含まれている場合、これはどのように発生するのでしょうか?

4

1 に答える 1

1

問題は、jquery-ui-1.8.18.custom.min.js が AMD モジュールではないことです。

解決策 1: jquery-ui のコードを AMD モジュールにラップする

解決策 2: コード内の依存関係を削除し、手動で含めます。

AMD以外の依存関係を処理する方法は他にもありますが、その場合にオプティマイザーがどのように機能するかはわかりません。

于 2012-06-25T14:28:48.110 に答える