【发布时间】:2021-04-11 14:20:25
【问题描述】:
这是我的方法:
Object.entries(query).forEach(([key, value]) => {
if (key === 'team_ids') {
if (typeof value === 'string') {
this.items.push(this.$store.getters.teamById(value));
} else {
value.forEach((itemId) => {
this.items.push(this.$store.getters.teamById(itemId));
});
}
else if (key === 'close_ids') {
if (typeof value === 'string') {
this.items.push(this.$store.getters.closeFriendsById(value));
} else {
value.forEach((friendId) => {
this.items.push(this.$store.getters.closeFriendsById(friendId));
});
}
} else {
if (key === 'name') this.name = value;
if (key === 'patr') this.patr= value;
}
});
我正在尝试重构它,但现在我被难住了......
它看起来不太好。
有什么建议吗?
【问题讨论】:
-
你想重构什么,为什么?
标签: javascript vue.js vuex