我已經使用npm install jQuery --save
安裝了最新版本的jQuery。jQuery的signalR選擇模塊?
This operation created modules folders in the node_modules
folder.
由於signalr(客戶端)依靠jQuery的 - 我能做到這一點:
var jQuery = require('jquery'); // — All jQuery modules
window.$ = window.jQuery=jQuery;
require('./jquery.signalR-2.2.1.min.js'); // works since it searches window.jQuery
最終的軟件包(包括我的代碼,精縮)是〜164 KB,大部分它是jQuery,我不需要所有的jQuery模塊!
於是我開始選擇性加載模塊:
var jQuery = require('jquery/src/core');
window.$ = window.jQuery=jQuery;
require('./jquery.signalR-2.2.1.min.js');
Error: Uncaught TypeError: v.fn.init is not a constructor
然後我又說:
var jQuery = require('jquery/src/core');
require('jquery/src/core/init');
window.$ = window.jQuery=jQuery;
require('./jquery.signalR-2.2.1.js');
Different Error: Uncaught TypeError: _pageWindow.load is not a function
現在我不知道哪個額外的模塊,我應該加載。
問:
我要加載的jQuery的(3.1.1)模塊(以及以什麼順序)爲了signalR(V2.2.1)工作?
我不想將所有jQuery的無關函數加載到我的包中,只是爲了讓signalr運行。
在第4號 - 你在哪裏調用jQuery的grunt? –
@Royi在步驟1中從zip壓縮的目錄 – blackmiaool
好吧,我會測試它(如果信號工程),tnx –