FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-api-cn/path/path_format_pathobject.md at master · nodejscn/node-api-cn · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nodejscn
/
node-api-cn
Public
Notifications
You must be signed in to change notification settings
Fork
1.3k
Star
1.4k
Code
Issues
1
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-api-cn
/
path
/
path_format_pathobject.md
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (51 loc) · 1.29 KB
Breadcrumbs
node-api-cn
/
path
/
path_format_pathobject.md
Copy path
File metadata and controls
62 lines (51 loc) · 1.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!-- YAML
added:
v0
.11
.15
-->
*
`pathObject`
{
Object
}
*
`dir`
{
string
}
*
`root`
{
string
}
*
`base`
{
string
}
*
`name`
{
string
}
*
`ext`
{
string
}
*
返回:
{
string
}
`path.format()`
方法从对象返回路径字符串。
与
[
`path.parse()`
]
相反。
当为
`pathObject`
提供属性时,注意以下组合,其中一些属性优先于另一些属性:
*
如果提供了
`pathObject.dir`
,则忽略
`pathObject.root`
。
*
如果
`pathObject.base`
存在,则忽略
`pathObject.ext`
和
`pathObject.name`
。
例如,在
POSIX
上:
``
`js
// 如果提供了 `
dir
`、`
root
` 和 `
base
`,
// 则返回 `
$
{
dir
}
$
{
path
.
sep
}
$
{
base
}
`。
// `
root
` 会被忽略。
path.format({
root: '/ignored',
dir: '/home/user/dir',
base: 'file.txt'
});
// 返回: '/home/user/dir/file.txt'
// 如果未指定 `
dir
`,则使用 `
root
`。
// 如果只提供 `
root
`,或 'dir`
等于
`root`
,则将不包括平台分隔符。
// `ext` 将被忽略。
path
.
format
(
{
root
:
'/'
,
base
:
'file.txt'
,
ext
:
'ignored'
}
)
;
// 返回: '/file.txt'
// 如果未指定 `base`,则使用 `name` + `ext`。
path
.
format
(
{
root
:
'/'
,
name
:
'file'
,
ext
:
'.txt'
}
)
;
// 返回: '/file.txt'
``
`
在 Windows 上:
`
``
js
path
.
format
(
{
dir
:
'C:\\path\\dir'
,
base
:
'file.txt'
}
)
;
// 返回: 'C:\\path\\dir\\file.txt'
``
`
Back
|
FazBrowse Home
|
New Git URL