写法优化

This commit is contained in:
fofolee
2022-04-03 22:19:47 +08:00
parent 8ae8f52212
commit cfdd5a7e71
2 changed files with 3 additions and 3 deletions

View File

@@ -235,8 +235,7 @@ export default {
// 默认命令不可删除
canCommandEdit() {
if (utools.isDev()) return true;
let tags = this.commandInfo.tags;
return tags && tags.includes("默认") ? false : true;
return this.commandInfo.tags?.includes("默认") ? false : true;
},
// 匹配类型的颜色
cmdBadgeColor() {

View File

@@ -325,7 +325,8 @@ export default {
);
default:
return commands.filter(
(cmd) => cmd.tags && cmd.tags.includes(this.currentTag)
// 可选链操作符
(cmd) => cmd.tags?.includes(this.currentTag)
);
}
},