This article mainly introduces node. path. the resolve method is described in this article. resolve Method description, receiving parameters, syntax, use instances and implementation source code. For more information, see
Method description:
Resolve the characters at the "to" parameter to an absolute path.
Syntax:
The Code is as follows:
Path. resolve ([from...],)
Because this method belongs to the path module, You need to introduce the path module (var path = require ("path") before use "))
Receiving parameters:
From Source Path
To the string to be parsed to the absolute path
Example:
The Code is as follows:
Path. resolve ('/foo/bar','./Baz ')
// Returns
'/Foo/bar/Baz'
Path. resolve ('/foo/bar','/tmp/file /')
// Returns
'/Tmp/file'
Path. resolve ('wwwroot', 'static _ files/png/',' ../gif/image.gif ')
// If currently in/home/myself/node, it returns
'/Home/myself/node/wwwroot/static_files/gif/image.gif'
Another method is to use it as the cd command shell of a sequence.
The Code is as follows:
Path. resolve ('foo/bar', '/tmp/file/', '...', 'A/../subfile ')
Similar:
The Code is as follows:
Cd foo/bar
Cd/tmp/file/
Cd ..
Cd a/../subfile
Pwd