Bom*_*ber 5 javascript object ecmascript-6
如何解构嵌套的routesandindex并设置默认值?
const {
nav: { index: navIndex = '', routes: navRoutes = '' }
routes = '', index = ''
} = _navigator.state;
Run Code Online (Sandbox Code Playgroud)
我想将嵌套值重命名为navIndexand navRoutes,有什么想法吗?
nav您可以为未给定的对象采用默认对象
const {
nav: { index: navIndex = '', routes: navRoutes = '' } = {},
routes = '',
index = ''
} = _navigator.state;
Run Code Online (Sandbox Code Playgroud)