我目前正在遍历一个数组,然后尝试遍历一个对象
return optionsGroup.map(optionItem => {
return (
<span className="select-wrapper-size {{selectExtraclassNameDetail}}" data-ng-show="variation_exist">
<select className="form-control size-select" name="size" required>
<option value="" selected>Select {optionItem}</option>
{ Object.keys(shopProduct['options'].map(optEl => {
return (<option data-ng-repeat="var in variations" value="{{var}}">{optEl[optionItem]}</option>)
}))
}
</select>
</span>
)上面的原样显示在html端,但缺少此区域:
{ Object.keys(shopProduct['options'].map(optEl => {
return (<option data-ng-repeat="var in variations" value="{{var}}">{optEl[optionItem]}</option>)
}))
}它没有被返回,所以我尝试这样做:
{ return Object.keys(shopProduct['options'].map(optEl => {
return (<option data-ng-repeat="var in variations" value="{{var}}">{optEl[optionItem]}</option>)
}))
}这给了我一个语法错误。我的问题是如何返回嵌套的Object.keys映射?
发布于 2020-07-08 03:38:52
看起来在.map方法之前缺少了一个花括号
{ Object.keys(shopProduct['options']).map(optEl => {
return (<option data-ng-repeat="var in variations" value="{{var}}">{optEl[optionItem]}</option>)
}))
}https://stackoverflow.com/questions/62782670
复制相似问题