这个问题困扰了我两天,使用别人的例子、官网down下来的example都没有问题。但是放到自己项目里就 var $=require("jquery") 为null。

后来发现,jquery本来没有amd规范的,于是从官网上的example下来里面的jquery拿过来直接用,最注意的是,在jquery里面增加了有define这段,里面有一个路径要根据自己实际项目路径进行调整

if ( typeof module === "object" && module && typeof module.exports === "object" ) {
// Expose jQuery as module.exports in loaders that implement the Node
// module pattern (including browserify). Do not create the global, since
// the user will be storing it themselves locally, and globals are frowned
// upon in the Node module world.
module.exports = jQuery;
} else {
// Otherwise expose jQuery to the global object as usual
window.jQuery = window.$ = jQuery; // Register as a named AMD module, since jQuery can be concatenated with other
// files that may use define, but not via a proper concatenation script that
// understands anonymous AMD modules. A named AMD is safest and most robust
// way to register. Lowercase jquery is used because AMD module names are
// derived from file names, and jQuery is normally delivered in a lowercase
// file name. Do this after creating the global so that if an AMD module wants
// to call noConflict to hide this version of jQuery, it will work.
if ( typeof define === "function" ) {
define("lib/jquery/jquery/1.10.1/jquery-debug",[], function () { return jQuery; } );
}
}

  原文:http://blog.csdn.net/adeyi/article/details/18003043

使用SeaJS,require加载Jquery的时候总是为null的更多相关文章

  1. seajs加载jquery时提示$ is not a function该怎么解决

    这篇文章主要介绍了seajs加载jquery时提示$ is not a function该怎么解决的相关资料,需要的朋友可以参考下 jquery1.7以上的都支持模块化加载,只是jquery默认的是支 ...

  2. 在seajs中使用require加载静态文件的问题

    注意,在seajs中使用require加载静态文件时,必须使用常量,不能用变量.如果一定要用变量,请使用require.async var html = require("view/sys/ ...

  3. seajs加载jquery提示$ is not a function

    jquery1.7以上的都支持模块化加载,只是jquery默认的是支持amd,不支持cmd.所以要用seajs加载jquery,需要稍微改下jquery 把 if (typeof define === ...

  4. 测试加载jquery

    Hello world! <h1 id="main-heading">Hello world!</h1> <p><img onclick= ...

  5. 优化加载jQuery的方法

    请看下面的一段代码: <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" ...

  6. 加载jquery插件注意了

    1.尽量放在</body>之前,不要放在</head>标签之前,如果执意要放也要放在css之后,例如: <link href="style.css" ...

  7. 谈谈动态地加载Jquery库文件的方法

    有时候,我们可能不会在网页中<script src="jquery.min.js" 来加载 Jquery 库,可能在用户点击某个按钮后,才去加载 Jquery 库. 好处不用 ...

  8. selenium 加载jquery

    packagecom.example.tests; import staticorg.junit.Assert.*; importjava.util.*; importorg.junit.*; imp ...

  9. 使用Application.GetResourceStream方法加载资源时得到的总是null

    我们可以预先把程序中用到的资源,如图片,音乐等放入项目中,打包进XAP文档,需要的时候从中调用.下面就说说具体实现方法. 第一步,把数据存进项目. 1.右键点击项目名称-添加-新建文件夹(英文版请自行 ...

随机推荐

  1. POJ2184 Cow Exhibition 背包

    题目大意:已知c[i]...c[n]及f[i]...f[n],现要选出一些i,使得当sum{c[i]}和sum{f[i]}均非负时,sum(c[i]+f[i])的最大值. 以sum(c[i])(c[i ...

  2. 【SCOI 2005】 骑士精神

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1085 [算法] IDA* [代码] #include<bits/stdc++. ...

  3. EOJ 3031 二进制倒置

    题目描述 给定一个整数 n(0≤n≤10100).将 n 的 334 位二进制表示形式(不包括开头可能的值为 0 的位,n=0 表示为 1 位 0)前后倒置,输出倒置后的二进制数对应的整数. 例如:n ...

  4. [HTML] 微信开发之移动手机WEB页面(HTML5)Javascript实现一键拨号及短信发送功能

    在做一个微信的微网站中的一个便民服务电话功能的应用,用到移动web页面中列出的电话号码,点击需要实现调用通讯录,网页一键拨号的拨打电话功能. 如果需要在移动浏览器中实现拨打电话,发送email,美国服 ...

  5. 使用autofac在mvc5下依赖注入

    把遇到的问题汇总一下: 一.安装mvc5版本 命令:pm> Install-Package Autofac 结果安装的Autofac.Integration.Mvc(版本为4.0),所引用的依赖 ...

  6. jquery.slides.js

    http://slidesjs.com/#docs 一款强大的,专业的幻灯片组件,全方位对幻灯片的速度..全方位的控制: $(function(){ $("#slides").sl ...

  7. 找不到dll原因

    1.没有生成成功: A.代码有错误 B.引用dll有问题(dll生成失败|dll版本不对) C.源文件损坏 2.dll生成路径不对 3.对dll的引用丢失

  8. 第7章 性能和可靠性模式 Failover Cluster(故障转移群集)

    上下文 您已经决定在设计或修改基础结构层时使用群集以提供高度可用的服务. 问题 您应该如何设计一个高度可用的基础结构层,来防止因单台服务器或它所运行的软件出现故障而导致的服务丢失? 影响因素 在设计高 ...

  9. Android拼图-变形金刚

    开篇 学了几个月的Android开发,动手做了一个简单的拼图小游戏,没有使用游戏框架,名字也纯属娱乐,比较粗糙请大家一笑别骂. 游戏界面是一张图片切割的6*6的小图片,并将其中一块拿走,玩家通过不同的 ...

  10. RecyclerView实现终极画廊效果 中间突出并且压住两侧布局

    先给大家上个gif 要不然下面很枯燥 忘记原来在哪里看到了..... 这个效果我找了NNNNNN长时间,,,我认为凭我现在的能力 写出来需要好久 所以 退而求其次找大神写好的... 你们不要小看了这个 ...