From e85ef78c1a04335df6fc549278553230606c3cd0 Mon Sep 17 00:00:00 2001 From: dyz <43943819+dyzsoft@users.noreply.github.com> Date: Sun, 5 Jul 2020 08:19:56 +0800 Subject: [PATCH] update permission.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some包含返回true,不包含返回false,if判断中直接返回some函数结果,精简代码逻辑 --- src/utils/permission.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils/permission.js b/src/utils/permission.js index 221d3842..8e2bbada 100644 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -13,11 +13,7 @@ export default function checkPermission(value) { const hasPermission = roles.some(role => { return permissionRoles.includes(role) }) - - if (!hasPermission) { - return false - } - return true + return hasPermission } else { console.error(`need roles! Like v-permission="['admin','editor']"`) return false