gpt4 book ai didi

javascript - 在 react-native 错误中传播数组解构

转载 作者:行者123 更新时间:2023-11-30 11:51:21 26 4
gpt4 key购买 nike

以下代码:

const [ ...routes, currentRoute ] = props.routes

在这样的行上产生一个unexpected token 错误。

这是为什么?

最佳答案

您可以使用 rest operator仅在解构表达式的末尾,例如:

const [ currentRoute, ...routes ] = props.routes.reverse()

ECMAScript 2015 Spec.#Destructuring Assignment 中说明,它可能很难阅读,但请查看 ArrayAssignmentPattern 结构。

关于javascript - 在 react-native 错误中传播数组解构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39368003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com