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

require函数参数问题 #28

Open
ovimp opened this issue Mar 4, 2016 · 2 comments
Open

require函数参数问题 #28

ovimp opened this issue Mar 4, 2016 · 2 comments

Comments

@ovimp
Copy link

ovimp commented Mar 4, 2016

刚开始学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字符串也行,说清楚,减少初学者弯路。

我还是继续往下读文档吧。。。

@ovimp
Copy link
Author

ovimp commented Mar 4, 2016

在文档组织的不够调理,一开始就应该把这个“模块标识”的概念加入
seajs/seajs#258

@yoqo
Copy link

yoqo commented Sep 3, 2016

相对于config里base的路径

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

2 participants