node.js中的url.resolve方法使用说明
2018-10-12 14:06
771 查看
方法说明:
为URL或 href 插入 或 替换原有的标签。(不懂可以看例子)
语法:
url.resolve(from, to)
由于该方法属于url模块,使用前需要引入url模块(var url= require(“url”) )
接收参数:
from 源地址
to 需要添加或替换的标签
例子:
var url = require('url');
var a = url.resolve('/one/two/three', 'four') ,
b = url.resolve('http://example.com/', '/one'),
c = url.resolve('http://example.com/one', '/two');
console.log(a +","+ b +","+ c);
//输出结果:
///one/two/four
//http://example.com/one
//http://example.com/two
源码:
Url.prototype.resolve = function(relative) {
return this.resolveObject(urlParse(relative, false, true)).format();
};
您可能感兴趣的文章:
相关文章推荐
- node.js中的url.resolve方法使用说明
- node.js中的url.resolve方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的url.format方法使用说明
- node.js中的url.parse方法使用说明
- node.js中的url.parse方法使用说明
- node.js中的url.parse方法使用说明
- node.js中的url.parse方法使用说明
- node.js中的url.parse方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的path.resolve方法使用说明
- node.js中的url.format方法使用说明
- node.js中的console.log方法使用说明
- node.js中的path.basename方法使用说明
- node.js中的buffer.write方法使用说明
- node.js中的http.request.end方法使用说明
- node.js中的path.dirname方法使用说明
- node.js中的buffer.Buffer.byteLength方法使用说明
- node.js中的console.info方法使用说明
- node.js中的console.time方法使用说明