我无法理解我错过了什么?
错误:“意外的令牌,预期,”
此部分中出现错误value === ''
代码:
return {
iteams: {
todos: {
value === '' ? filteredTodos.sort((a, b) => b.id - a.id)
: value !== '' ? filteredSearchTodos.sort((a, b) => b.id - a.id)
: state.iteams.todos.sort((a, b) => b.id - a.id)
},
buttons: {
value === '' ? filteredButtons.sort((a, b) => b.id - a.id)
: value !== '' ? filteredSearchButtons.sort((a, b) => b.id - a.id)
: state.iteams.buttons.sort((a, b) => b.id - a.id),
}
},
value: value,
filter: filter,
tempFilter: tempFilter
};
答案 0 :(得分:1)
似乎todos
和buttons
应该是值数组 - 因此您要删除{}
和todos
buttons
todos:
value === '' ? filteredTodos.sort((a, b) => b.id - a.id)
: value !== '' ? filteredSearchTodos.sort((a, b) => b.id - a.id)
: state.iteams.todos.sort((a, b) => b.id - a.id)
,
和buttons:
目前,您的代码相当于
todos:{[1,2,3]}
这是无效的javascript
你想要的是
todos:[1,2,3]