let { user:{id=1,name='hello'}} = {};
console.log(typeof(name));
console.log(name);
这里因为被解构的对象肯定不存在user 所以name自然没。
因为解构时可设置默认值。所以请问如何给 user这个对象设置默认值呢?
谢谢。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
额。。。。 多试了下 尝试出来了。