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

{}路径后面要不要跟'/'路径分隔符啊? #16

Open
lcoder opened this issue Nov 2, 2016 · 3 comments
Open

{}路径后面要不要跟'/'路径分隔符啊? #16

lcoder opened this issue Nov 2, 2016 · 3 comments

Comments

@lcoder
Copy link

lcoder commented Nov 2, 2016

NEJ.define([
    'A/extend/util',
    '{A}extend/util.js'    // {A}后面没有'/'
],function(u1,u2){

    // 这里需要注意的是如果使用{A}形式需要加后缀.js
    // 这里两种方式引入的为同一个文件都是 ../web/js/extend/util.js 文件

});
NEJ.define([
    'pro/api/element',
    '{pro}/api/element.js'  // {pro}后面加了路径分隔符'/'
],function(e1,e2){

    // 以上两种方式访问的为同一个文件都是 ./api/element.js 文件

});

问题:{variable} 花括号中的路径变量后要不要路径分隔符啊?可以试出来,不过还没跑,希望文档能写清楚点。

补充,刚问了,貌似都行啊。

@AndyRightNow
Copy link

According to the implementation of directory specifiers such as '{pro}' or '{platform}', specifiers are replaced by the directories you provide. Therefore after parsing, it may end up being something like 'yourbase//api/element'. However, these kinds of URIs will be formatted before getting loaded so it is not really an issue.

Conclusion: Either adding a slash or not is fine. They will be formatted eventually anyway.

For more implementation details, you can check out my naive analysis of this framework. It is a work in progress and the analysis of define.js is mostly done.

@genify
Copy link
Owner

genify commented Dec 2, 2016

@AndyRightNow 好认真啊, 大赞,NEJ 目前主要应用于网易内部的产品,配合 https://github.com/genify/toolkit2 打包工具做内部整体方案,目前内部UI组件的构建主要会基于 https://github.com/regularjs/regular , NEJ相关的一些解决方案的文档在 doc 下面,如有需要我也可以把内部 NEJ 相关的一些培训资料发你看看

@AndyRightNow
Copy link

@genify 好的好的,非常感谢蔡大神,如果您方便的话可以麻烦您发到这个邮箱 [email protected] 吗?

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

3 participants