Skip to content

Functions ​

getFileTypeByExtName() ​

getFileTypeByExtName(extName): undefined | string

根据扩展名获取常用文件类型

Parameters ​

ParameterTypeDescription
extNamestring扩展名

Returns ​

undefined | string

Example ​

ts
console.log(getFileTypeByExtName(''))
// => undefined

console.log(getFileTypeByExtName('png'))
// => 'image/png'

console.log(getFileTypeByExtName('.html'))
// => 'text/html'