seajs / examples Goto Github PK
View Code? Open in Web Editor NEWExamples for Sea.js
Examples for Sea.js
rt
我本地重新构建后也是不行的,难道配置或文件要升级么?
@army8735 A神帮忙看看这个问题噢,Chrome上面没问题的
页面地址 :http://seajs.github.io/examples/app/hello.html
期望:网络链接里应该跟sea-debug.js一点关系都没啊。
结果:main.js,jquery.js的initiator是sea-debug.js。
其他问题:
jquery-1.10.1.min.map,sea.js.map 是干嘛的,怎么加载的?
使用v0.2.2版本的grunt-cmd-concat时,按照示例的配置build,发现并没有合并文件,查看concat的文档发现选项应为:include: relative
chrome浏览器上面,当双击某一项编辑过后,blur的时候,此项被删除
Hello,刚开始学习seajs,使用require加载jquery时报TypeError: $ is not a function的错。在issue里找到了相关的一些解决办法,#12,#930,#438,试过里面的解决方法但还是没有进展~~
我使用的是spm下载下来的2.1.1版jquery库,模块id是jquery/2.1.1/jquery,
if ( typeof define === "function" && define.amd ) {
define( "jquery/2.1.1/jquery", [], function() {
return jQuery;
});
}
seajs.config:
seajs.config({
base: './sea-modules/',
alias: {
'jquery': 'jquery/2.1.1/jquery.js'
}
});
因为是从spm下载的,jquery库放在sea-modules里面,按照在#879里的方法,base路径+id名称,我应该是可以用require取到的~~
另外,还有一个不解之处,我发现在FF的net里有2个jquery资源的请求,一个获取到了资源(type=js),另一个没有取到(type=plain/html),没取到的也没有报404,请问这是什么机制呢?
被这个问题彻底搞困惑了,接触seajs没几天, 一直被如何引入jquery 而困扰. 我怎么感觉jquery 必须放在 jquery/jquery/1.10.1/jquery.js 才能生效呢?
目录结构很简单, 所有文件都在一个目录中, index.html, application.js, jquery.js
index.html:
<script src="sea.js" ></script><script>
seajs.config({
base: "./",
alias: {
"jquery": "jquery.js" // 换成"jquery/jquery/1.10.1/jquery.js", 并将jquery放入这个位置就没有问题。
}
});
seajs.use("./application");
</script>
application.js:
define(function(require,exports,module){
var $ = require('jquery');
console.log($("#xxx").html());
});
jquery.js 来自 seajs-master example/sea-modules/jquery/jquery/1.10.1/jquery.js
错误是: TypeError: $ is not a function,
debug seajs.cache
jquery 其实已经被加载进来了。。。
但是发现还有一个 http://localhost:8080/plugins/seajs/mktry/jquery/jquery/1.10.1/jquery.js
这个就不知道从哪里来的了。。。
期待您的回复 :)
seajs.config({
base: "../sea-modules/",
alias: {
"$": "jquery/jquery/1.10.1/jquery.js",
"underscore": "gallery/underscore/1.6.0/underscore.js",
"backbone": "gallery/backbone/1.1.2/backbone.js"
}
});
换成新版本的backbone报错了。
TypeError: b.$ is not a function
http://127.0.0.1:8020/seajs-examples/sea-modules/gallery/backbone/1.1.2/backbone.js
Line 1
请问windows下怎么运行Makefile文件?
按照 examples 做了个测试,build 正常,deploy 错误,望指教,thx
bogon:hello mittya$ spm deploy
Task: "scp:assets" (scp) task
error: error getaddrinfo ENOTFOUND
ssh: close assets.dev.*.net
warn: [Error: Task "scp:assets" failed.]
Done: but with warnings.
刚开始学sea.js ,看了这个hello的例子,发现文档确实讲的模棱两可。比如这个例子在dev模式中static\hello\src\main.js的代码如下:
define(function(require) {
var Spinning = require('./spinning');
// var Spinning = require('./spinning.js'); //需要加.js后缀吗?
var s = new Spinning('#container');
s.render();
});
这里作为初学者,我有两点疑问:
问题1:下面的路径 ./spinning 是相对于哪里的路径?是相对于网页hello.html的路径,可是hello.html里面没有spinning.js。所以猜测:应该是相对于当前main.js的路径,表示main.js当前目录下的spinning.js
问题2:为什么var Spinning = require('./spinning'); 这里没有加后缀 .js ,我看前面的教程,这里都有过加后缀.js ,或者用seajs.config.alias 来定义一下.js的别名也行。这种例子和文档实在是不详细,应该明确说明函数 require()的参数类型是什么格式的字符串嘛: 是接字符串的js文件路径,是也可以用js文件路径的alias字符串也行,说清楚,减少初学者弯路。
我还是继续往下读文档吧。。。
alias: {
'jquery':'/js/lib/jquery-1.10.2.min.js'
},
请问我用这种方式配置别名,
然后var $ = require('jquery'); 这个$为null
如果直接require('jquery');就没问题
这是为什么,这跟示例不一样啊
能否开放例子中的源码,混淆的代码俺菜鸟看不懂呢额额
一个独立的模块如何引入jQuery?
我下载这个例子测试:改变jquery文件的位置,代码中的路径也同时修改正确,控制台看到是成功加载了jquery文件的,但模块中并没有jquery对象。我哪里出错了?
https://github.com/seajs/examples/blob/master/static/hello/Makefile
windows git bash該怎麼用,可以給個例子嗎?
感謝
看了官网的hello的example,如果要使用构建后的脚本,页面上我这样使用的:
1、引入脚本
script src="static/seajs/sea.js?t=20130306
script src="static/hello/dist/main.js?t=20130306
2、添加配置和启动运行
这样就可以运行了,所以对于构建或者实际的开发应用我可以这样理解吗:
如果我依赖于zepto和seajs做开发,
第一步:把seajs和zepto在保留版权的情况下压缩为一个脚本
第二步:业务逻辑依赖的所有模块通过build压缩为一个脚本
第三步:使用seajs.use(["入口模块"])
这样的话页面上js的请求数就可以变为只有两个了,不知道理解是否到位,还请点播一下,谢谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.