Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在下载到 jquery 时,这样配置为什么会出现调用不到 jquery 的现象呢?貌似是路径的问题,刚刚学习到seajs,不知该怎么理解呢 #978

Closed
lfrhcxx opened this issue Oct 11, 2013 · 11 comments

Comments

@lfrhcxx
Copy link

lfrhcxx commented Oct 11, 2013

seajs.config({
base:"../path/",
alias: {
"jquery":"../path/jquery/jquery.js"
}
});
按照官方的的配置可以调用的以下是官方的配置
seajs.config({
base:"../path/",
alias: {
"jquery":"../path/jquery/jquery/1.10.1/jquery.js"
}
});

@lizzie
Copy link
Member

lizzie commented Oct 11, 2013

控制台报什么错? jquery.js 404 吗?

@lfrhcxx
Copy link
Author

lfrhcxx commented Oct 11, 2013

当上面配置时
var $ = require("jquery");
当调用 $("dom") 元素时,控制台会报 “Uncaught TypeError: object is not a function"

@lfrhcxx
Copy link
Author

lfrhcxx commented Oct 11, 2013

控制台上可以看到 jquery 是正常加载进来了的

@lizzie
Copy link
Member

lizzie commented Oct 11, 2013

  1. $ 是什么?

  2. 控制台打印下 seajs.cache 值是多少

@afc163
Copy link
Member

afc163 commented Oct 12, 2013

目测 #930

@jiangtao
Copy link

我也遇到类似的情况 jQuery.js 是正常加载进来的 状态是200 但是在define的时候出现
define(function(require, exports, module) {
var $ = require('jquery');
console.log(require.resolve('jquery'));
console.log($); // null
});

@afc163
Copy link
Member

afc163 commented Oct 23, 2013

jQuery 文件长啥样?

@frankLife
Copy link

与上面相同的情况,用的jq的文件就是demo里面的jquery.js

@jiangtao
Copy link

嗯 搞定啦。。
jQuery默认的是cmd ,改成amd ;
用上面改过的就好啦

@lifesinger
Copy link
Member

搞定了就好,可以说下原因,说不定能帮助到其他人。

@liy-cn
Copy link

liy-cn commented Nov 8, 2016

@Jerret321 的意思是把amd改成cmd吧?我这样试了一下就好了

...
function"==typeof define&&define.cmd&&define("jquery",
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants