在進行DW開發時,我們可能會需要使用到jQuery這個優秀的JS庫,那么在DW中該如何導入呢?下面將為大家介紹具體的操作流程。
首先,我們需要下載jQuery庫文件,可以去jQuery官網下載,也可以在其他網站進行下載。下載完成后,我們將jQuery.js文件保存到本地。
// jQuery.js代碼示例: (function( global, factory ) { "use strict"; if ( typeof module === "object" && typeof module.exports === "object" ) { // For CommonJS and CommonJS-like environments where a proper `window` // is present, execute the factory and get jQuery. // For environments that do not have a `window` with a `document` // (such as Node.js), expose a factory as module.exports. // This accentuates the need for the creation of a real `window`. // e.g. var jQuery = require("jquery")(window); // See ticket #14549 for more info. module.exports = global.document ? factory( global, true ) : function( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); }; } else { factory( global ); } // Pass this if window is not defined yet }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { var deletedIds = []; var document = window.document; var slice = deletedIds.slice; var concat = deletedIds.concat; var push = deletedIds.push; var indexOf = deletedIds.indexOf; var class2type = {}; var toString = class2type.toString; ……
然后,我們要將jQuery.js導入到DW中。打開我們的DW,新建一個HTML頁面,并在頭部添加