如何从完整文件 URL 中提取文件基本名称?
FileDialog
{
id: fileDialog
title: "Oooopen"
onAccepted:
{
console.log(fileUrl)
}
}
Run Code Online (Sandbox Code Playgroud)
fileUrl没有像baseName我尝试谷歌搜索的属性,但没有成功
您可以定义自己的basename函数
function basename(str)
{
return (str.slice(str.lastIndexOf("/")+1))
}
FileDialog
{
id: fileDialog
title: "Oooopen"
onAccepted:
{
console.log(basename(fileUrl.toString()))
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3948 次 |
| 最近记录: |