研究了2个多小时,终于搞定引入jqcss
<h1>ddddddddd</h1> <script src='/Scripts/dist/sea.js'></script>
// seajs 的简单配置 seajs.config({ //base: "",//默认和sea.js同级,jquery.js和它同级,因此没有写;注意:若是为默认不要写,不然路径出错 alias: { "jquery": "jquery.js" } });
可是,这样就query不能直接使用,须要修改jq文件html
define(function () { //juery原文件内容 return $.noConflict(); });
好了,这样就解决了jquery
这部门内容一般是写在js文件里,这里为了方便直接写在代码中ui
// 全部模块都经过 define 来定义 define("test", ["jquery"], function (require, exports, module) { // 经过 require 引入依赖 var $ = require('jquery'); // 经过 exports 对外提供接口 exports.doSomething = function () { alert(1); return 1; } function Test(h1) { this.h1 = $(h1); } // 或者经过 module.exports 提供整个接口 module.exports = Test; Test.prototype.change = function () { var h1 = this.h1; $(h1).css("color", "red"); } }); define("main", ["test", "jquery"], function (require, exports, module) { var t = require('test'); var tt = new t("h1"); tt.change(); });
// 加载入口模块 seajs.use("main");