首页 > web前端 > js教程 > 正文

node.js中的path.join方法使用说明_node.js

php中文网
发布: 2016-05-16 16:28:18
原创
2067人浏览过

方法说明:

将多个参数组合成一个 path (详细请看例子)

语法:

复制代码 代码如下:

path.join([path1], [path2], [...])

由于该方法属于path模块,使用前需要引入path模块(var path= require(“path”) )

例子:

淘淘乐商城整站 For ECSHOP
淘淘乐商城整站 For ECSHOP

基于ECSHOP2.7.2制作,模板使用的是早期的凡客模板。整站大气,清爽。适合综合,鞋子,服饰类商城使用。具体安装方法在程序包中有说明,在使用之前请看下。 大体方法:1.上传程序至网站根目录,访问:域名/diguo (用户名:admin 密码:123456)2.设置好数据库信息,然后恢复数据,数据目录在www.shopex5.com下.3.修改data目录下的config数据库配置文件。4.登陆

淘淘乐商城整站 For ECSHOP 0
查看详情 淘淘乐商城整站 For ECSHOP

复制代码 代码如下:

path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
// returns
'/foo/bar/baz/asdf'
path.join('foo', {}, 'bar')
// throws exception
TypeError: Arguments to path.join must be strings

源码:

复制代码 代码如下:

// windows version
  exports.join = function() {
    function f(p) {
      if (!util.isString(p)) {
        throw new TypeError('Arguments to path.join must be strings');
      }
      return p;
    }
 
    var paths = Array.prototype.filter.call(arguments, f);
    var joined = paths.join('\');
 
    // Make sure that the joined path doesn't start with two slashes, because
    // normalize() will mistake it for an UNC path then.
    //
    // This step is skipped when it is very clear that the user actually
    // intended to point at an UNC path. This is assumed when the first
    // non-empty string arguments starts with exactly two slashes followed by
    // at least one more non-slash character.
    //
    // Note that for normalize() to treat a path as an UNC path it needs to
    // have at least 2 components, so we don't filter for that here.
    // This means that the user can use join to construct UNC paths from
    // a server name and a share name; for example:
    // path.join('//server', 'share') -> '\\server\share')
    if (!/^[\/]{2}[^\/]/.test(paths[0])) {
      joined = joined.replace(/^[\/]{2,}/, '\');
    }
 
    return exports.normalize(joined);
  };
相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号