预期的意外令牌。反应/终极版

时间:2018-04-04 23:00:58

标签: javascript reactjs redux react-redux

我无法理解我错过了什么?

  

错误:“意外的令牌,预期,”

此部分中出现错误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
    };

1 个答案:

答案 0 :(得分:1)

似乎todosbuttons应该是值数组 - 因此您要删除{}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]