检查文件是否以规定的拓展名为结尾

话不多说,看方法:

// 检查文件是否以规定的拓展名为结尾
        checkFile(name) {
            const reg = /(.txt|.html|.css|.js|.config|.json|.htm|.zip|.rar)$/;
            if (!reg.test(name)) {
                return false;
            } else {
                return true;
            }
        },

 

posted @ 2021-03-16 15:49  鹿lu  阅读(65)  评论(0编辑  收藏  举报