有什么办法可以做这样的事情吗?
if({color, size, shape} = this.props){ console.log('Received all props!'); } else { console.log('There are some missing props'); }
我想知道是否通过组件的道具收到了所有需要的数据,如果没有,则抛出错误。
用于创建可重用的组件。
javascript if-statement destructuring ecmascript-6
destructuring ×1
ecmascript-6 ×1
if-statement ×1
javascript ×1