1
私はRequire.jsモジュール(AMD)で関数とjQuery関数を定義し、それらをエクスポートしたいと思います。関数をエクスポートするのは簡単ですが、jQuery関数をエクスポートする方法はありますか?ありがとう!Require.jsでカスタムjQuery関数をエクスポートするには?
// filename: someModule.js
define(function (require, exports) {
function funcA() {}
$.fn.someFunc = function(callback) {
return this.someFunc1(xxx, callback);
};
$.fn.extend({
someFunc2: function() {}
});
exports.funcA = funcA;
// how to export $.fn.someFunc, so I can use it in another module?
// and how to export someFunc2?
});
私はこのように、このファイルを使用しています:あなたが持っている何
<script type="text/javascript">
require.config({
baseUrl: '/asset',
packages: [
...
]
});
require(['path/to/main.js'], function (main) {
main.init();
});
</script>
申し訳ありません。私は私のプロジェクトの構造のいくつかの詳細を省略したので、質問を更新しました。 'ejs'ファイルを変更するのではなく、main.jsでsomeModule.jsを要求することはできますか?ありがとう。 – cmal