使用SeaJS,require加载Jquery的时候总是为null
这个问题困扰了我两天,使用别人的例子、官网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的更多相关文章
- seajs加载jquery时提示$ is not a function该怎么解决
这篇文章主要介绍了seajs加载jquery时提示$ is not a function该怎么解决的相关资料,需要的朋友可以参考下 jquery1.7以上的都支持模块化加载,只是jquery默认的是支 ...
- 在seajs中使用require加载静态文件的问题
注意,在seajs中使用require加载静态文件时,必须使用常量,不能用变量.如果一定要用变量,请使用require.async var html = require("view/sys/ ...
- seajs加载jquery提示$ is not a function
jquery1.7以上的都支持模块化加载,只是jquery默认的是支持amd,不支持cmd.所以要用seajs加载jquery,需要稍微改下jquery 把 if (typeof define === ...
- 测试加载jquery
Hello world! <h1 id="main-heading">Hello world!</h1> <p><img onclick= ...
- 优化加载jQuery的方法
请看下面的一段代码: <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" ...
- 加载jquery插件注意了
1.尽量放在</body>之前,不要放在</head>标签之前,如果执意要放也要放在css之后,例如: <link href="style.css" ...
- 谈谈动态地加载Jquery库文件的方法
有时候,我们可能不会在网页中<script src="jquery.min.js" 来加载 Jquery 库,可能在用户点击某个按钮后,才去加载 Jquery 库. 好处不用 ...
- selenium 加载jquery
packagecom.example.tests; import staticorg.junit.Assert.*; importjava.util.*; importorg.junit.*; imp ...
- 使用Application.GetResourceStream方法加载资源时得到的总是null
我们可以预先把程序中用到的资源,如图片,音乐等放入项目中,打包进XAP文档,需要的时候从中调用.下面就说说具体实现方法. 第一步,把数据存进项目. 1.右键点击项目名称-添加-新建文件夹(英文版请自行 ...
随机推荐
- luogu3386 【模板】 二分图匹配
基本概念:二分图有两种节点:X节点和Y节点.如果X和Y可以匹配, 则X与Y连着一条边.每个X节点最多只能匹配一个Y节点,同时每个Y节点最多只能匹配一个X节点.最大匹配便是最多的匹配数. 交错路径:交错 ...
- Centos安装FastDFS+Nginx
一.安装环境: gcc:安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc: yum install gcc-c++ PCRE:PCRE(Perl C ...
- Linq的Except
https://msdn.microsoft.com/en-us/library/bb300779(v=vs.100).aspx , , , }; , , , }; var list = list1. ...
- hdu 1002(大数)
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Hdu-6230 2017CCPC-哈尔滨站 A.Palindrome Manacher 主席树
题面 题意:给你一个字符串,问你满足s[i]=s[2n-i]=s[2n+i-2]的子串(这子串长度为3n-2)有多少个,原字符串长度<=5e5 题解:对于这种子串,其实要满足2个回文,跑过一次M ...
- MySQL架构与SQL执行流程
MySQL架构设计 下面是一张MySQL的架构图: 上方各个组件的含义如下: Connectors 指的是不同语言中与SQL的交互 Management Serveices & Utiliti ...
- linux编译安装protobuf2.5.0
1.下载安装包 https://github.com/google/protobuf/releases?after=v3.0.0-alpha-4.1 找到相应的版本下载 2.解压安装包 #.tar.g ...
- webpack入门 --初级压缩
1.新建一个文件夹,再初始化npm: npm init 2.安装webpack,首先要全局安装,再本地安装: npm install webpack -g // 全局安装 npm install we ...
- Java 开源博客 Solo 1.1.0 发布 - 告别 GAE
Solo 1.1.0 正式发布了,感谢一直以来关注 B3log 开源的朋友! 在这个版本中,我们对项目结构和发布包进行了重大调整: 各式***尚未普及,所以决定去除 GAE 版本 H2 版本使用人数较 ...
- python爬虫:爬取凤凰指数
在知乎上看到的这个问题,讲讲我爬取过程中遇到的问题: 1.循环爬取其他页面,在其他项目中用循环一般可以搞定,可是这个,第一页和第二第三页的表格是不同的,所以要重新写规则,我懒,写了第一页后,就不想在写 ...