/1.4/docs/html/guideline/path.html
HTML | 161 lines | 157 code | 4 blank | 0 comment | 0 complexity | ed38a4c18ddb0f8d7e559c985288a86f MD5 | raw file
Possible License(s): Apache-2.0
- <!doctype html>
- <html lang="zh">
- <head>
- <meta charset="utf-8">
- <title>KISSY - A Powerful JavaScript Framework</title>
- <meta name="viewport"
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
- <script src="//g.alicdn.com/kissy/k/1.4.8/seed-min.js"></script>
- <script src="/1.4/source/guideline/templates/assets/jquery.min.js"></script>
- <script src="/1.4/source/guideline/templates/assets/script.js"></script>
- <link rel="stylesheet" href="/1.4/source/guideline/templates/assets/bootstrap.css">
- <link rel="stylesheet" href="/1.4/source/guideline/templates/assets/normalize.css">
- <link rel="stylesheet" href="/1.4/source/guideline/templates/assets/kissy.css">
- <link rel="stylesheet" href="/1.4/source/guideline/templates/assets/prettify.css">
- <link rel="stylesheet" href="/1.4/source/guideline/templates/assets/forkit.css">
- <script src="/1.4/source/guideline/api/assets/highlight.pack.js"></script>
- <link href="/1.4/source/guideline/api/assets/tomorrow-night-bright.css" rel=stylesheet />
- <link rel="shortcut icon" href="http://a.tbcdn.cn/s/kissy/favicon.ico">
- </head>
- <body class="">
- <nav id="sidebar">
- <header>
- <a href="/">
- <img src="http://gtms01.alicdn.com/tps/i1/T1MVbxFoRcXXchhRni-175-68.png" alt=""/>
- </a>
- </header>
- <ul>
- <li><a href="https://github.com/kissyteam/kissy">GitHub</a></li>
- <li><a href="/1.4/docs/html/guideline/why-kissy.html">为什么选择kissy</a></li>
- <li><a href="/1.4/docs/html/guideline/get-started.html">入门指南</a></li>
- <li><a href="/1.4/docs/html/api/">API Doc</a></li>
- <li><a href="/1.4/docs/html/coms.html" class="J_Coms J_NavComs">组件列表</a></li>
- <li><a href="https://github.com/minghe/generator-bee/wiki/generator-bee%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B">bee 项目构建器</a></li>
- <li class="nav-divider"><a href="https://www.npmjs.com/package/gulp-kmc">gulp-kmc</a></li>
- <li><a href="/index-1.3.html">v1.3</a></li>
- <li><a href="/index-1.2.html">v1.2</a></li>
- <li><a href="/index-1.1.6.html">v1.1.6</a></li>
- </ul>
- </nav>
- <div id="content">
- <article>
- <p><style>
- h3 {
- color:blue;
- }
- </style></p>
- <h1 id="path">path</h1>
- <blockquote>
- <p>当前浏览器地址的有关信息</p>
- </blockquote>
- <p>可以直接通过KISSY.Path调用:</p>
- <pre><code>KISSY.Path.do_sth();</code></pre>
- <p>也可以通过沙箱来调用</p>
- <pre><code>KISSY.use('path',function(S,Path){
- Path.do_sth();// 执行操作
- });</code></pre>
- <h3 id="basename-static-">basename() <code><static></code></h3>
- <p><code>basename(path,ext) => String</code></p>
- <p>获取域名中的文件名</p>
- <h4 id="parameter">parameter</h4>
- <ul>
- <li>path:String,路径字符串</li>
- <li>ext:String,需要过滤的扩展名,比如<code>.html</code></li>
- </ul>
- <h4 id="return">return</h4>
- <p>返回文件名</p>
- <h4 id="example">example</h4>
- <pre><code>Path.basename('http://www.taobao.com/index.html','.html');//=> index</code></pre>
- <h3 id="dirname-static-">dirname() <code><static></code></h3>
- <p><code>dirname(path) => String</code></p>
- <p>返回path所指的文件所在的目录路径</p>
- <h4 id="parameter">parameter</h4>
- <p>path(String),Path全称</p>
- <h4 id="example">example</h4>
- <pre><code>Path.dirname('/home/bachi/daily/index.html');//=>/home/bachi/daily</code></pre>
- <h3 id="extname-static-">extname() <code><static></code></h3>
- <p><code>extname(path) => String</code></p>
- <p>获取路径所指文件的扩展名,比如<code>.html</code></p>
- <h4 id="example">example</h4>
- <pre><code>Path.extname('/home/bachi/daily/index.html');//=> .html</code></pre>
- <h3 id="join-static-">join() <code><static></code></h3>
- <p><code>join(p1,p2,...) => String</code></p>
- <p>以此拼接p1、p2...,遇到<code>../</code>时回退一级目录</p>
- <h4 id="example">example</h4>
- <pre><code>// ../../ 表示回退两级目录
- Path.join('/home/bachi/daily/','project','../../','index.html');//=> /home/bachi/index.html</code></pre>
- <h3 id="normalize-static-">normalize() <code><static></code></h3>
- <p><code>normalize(path) => String</code></p>
- <p>将path中的无关内容清理掉,返回直接的路径信息</p>
- <h4 id="example">example</h4>
- <pre><code>Path.normalize('x/y/../z'); // => x/z/
- Path.normalize('x/y/z/../'); // => x/y/</code></pre>
- <h3 id="relative-static-">relative() <code><static></code></h3>
- <p><code>relative(from,to) => String</code></p>
- <p>计算相对路径</p>
- <h4 id="example">example</h4>
- <pre><code>Path.relative('x/','x/y/z'); // => 'y/z'
- Path.relative('x/t/z','x/'); // => '../../'</code></pre>
- <h3 id="resolve-static-">resolve() <code><static></code></h3>
- <p><code>resolve([from ...], to) => String</code></p>
- <p>得到绝对地址,算法逻辑参照NodeJS <a href="http://nodejs.org/api/path.html#path_path_resolve_from_to">Path.resolve</a>。</p>
- <h4 id="example">example</h4>
- <pre><code>KISSY.Path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
- // => 'wwwroot/static_files/gif/image.gif'
- KISSY.Path.resolve('/foo/bar', '/tmp/file/')
- // => '/tmp/file'</code></pre>
- <style>
- .github-btn {
- border: 0 none;
- overflow: hidden;
- margin-top:4px;
- }
- footer {
- border-top:1px solid #e2e2e2;
- padding-top:20px;
- clear:both;
- }
- /* iPhone 及以下 */
- @media only screen and (max-width: 767px) {
- .github-link {
- display:none;
- }
- }
- </style>
- </article>
- </div>
- <script>
- var S = KISSY;
- (function(){
- S.use('node',function(S){
- S.all('code').each(function(node){
- var className = node.attr('class');
- if(/^lang-/.test(className)){
- var tc = className.replace(/^lang-/,'');
- node.replaceClass(className,tc);
- }
- });
- hljs.tabReplace = ' ';
- hljs.initHighlighting();
- });
- })();
- (function(){
- var h3s = document.getElementsByTagName('h3');
- for(var i = 0;i<h3s.length;i++){
- var str = S.trim(h3s[i].innerHTML);
- try{
- str = str.match(/\w+/)[0];
- }catch(e){
- continue;
- }
- h3s[i].innerHTML = '<a name="'+str+'"></a>' + h3s[i].innerHTML;
- }
- })();
- </script>
- <script type="text/javascript" src="http://tajs.qq.com/stats?sId=39100375" charset="UTF-8"></script>
- </body>
- </html>